Add spring-batch- to module directory names (so folks can use mvn eclipse:eclipse if they want to).

BATCH-238: Remove hibernate support for the Daos.
This commit is contained in:
dsyer
2007-12-10 21:23:48 +00:00
parent 17705f27ab
commit 8ea331bfc7
884 changed files with 956 additions and 2352 deletions

View File

@@ -0,0 +1,42 @@
/*
* Copyright 2006-2007 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.batch.core.configuration;
/**
* Checked exception that indicates a name clash when registering
* {@link JobConfiguration} instances.
*
* @author Dave Syer
*
*/
public class DuplicateJobConfigurationException extends JobConfigurationException {
/**
* Create an exception with the given message.
*/
public DuplicateJobConfigurationException(String msg) {
super(msg);
}
/**
* @param msg The message to send to caller
* @param e the cause of the exception
*/
public DuplicateJobConfigurationException(String msg, Throwable e) {
super(msg, e);
}
}

View File

@@ -0,0 +1,118 @@
/*
* Copyright 2006-2007 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.batch.core.configuration;
import java.util.ArrayList;
import java.util.List;
import org.springframework.beans.factory.BeanNameAware;
/**
* Batch domain object representing a job configuration. JobConfiguration is an
* explicit abstraction representing the configuration of a job specified by a
* developer. It should be noted that restart policy is applied to the job as a
* whole and not to a step.
*
* @author Lucas Ward
* @author Dave Syer
*/
public class JobConfiguration implements BeanNameAware {
private List stepConfigurations = new ArrayList();
private String name;
private boolean restartable = false;
private int startLimit = Integer.MAX_VALUE;
/**
* Default constructor.
*/
public JobConfiguration() {
super();
}
/**
* Convenience constructor to immediately add name (which is mandatory but
* not final).
*
* @param name
*/
public JobConfiguration(String name) {
super();
this.name = name;
}
/**
* Set the name property if it is not already set. Because of the order of
* the callbacks in a Spring container the name property will be set first
* if it is present. Care is needed with bean definition inheritance - if a
* parent bean has a name, then its children need an explicit name as well,
* otherwise they will not be unique.
*
* @see org.springframework.beans.factory.BeanNameAware#setBeanName(java.lang.String)
*/
public void setBeanName(String name) {
if (this.name==null) {
this.name = name;
}
}
/**
* Set the name property. Always overrides the default value if this object
* is a Spring bean.
*
* @see #setBeanName(java.lang.String)
*/
public void setName(String name) {
this.name = name;
}
public String getName() {
return name;
}
public List getStepConfigurations() {
return stepConfigurations;
}
public void setSteps(List stepConfigurations) {
this.stepConfigurations.clear();
this.stepConfigurations.addAll(stepConfigurations);
}
public void addStep(StepConfiguration stepConfiguration) {
this.stepConfigurations.add(stepConfiguration);
}
public int getStartLimit() {
return startLimit;
}
public void setStartLimit(int startLimit) {
this.startLimit = startLimit;
}
public void setRestartable(boolean restartable) {
this.restartable = restartable;
}
public boolean isRestartable() {
return restartable;
}
}

View File

@@ -0,0 +1,42 @@
/*
* Copyright 2006-2007 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.batch.core.configuration;
/**
* Base class for checked exceptions related to {@link JobConfiguration}
* creation, registration or use.
*
* @author Dave Syer
*
*/
public class JobConfigurationException extends Exception {
/**
* Create an exception with the given message.
*/
public JobConfigurationException(String msg) {
super(msg);
}
/**
* @param msg The message to send to caller
* @param e the cause of the exception
*/
public JobConfigurationException(String msg, Throwable e) {
super(msg, e);
}
}

View File

@@ -0,0 +1,38 @@
/*
* Copyright 2006-2007 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.batch.core.configuration;
/**
* A runtime service locator interface for retrieving job configurations by
* <code>name</code>.
*
* @author Dave Syer
*
*/
public interface JobConfigurationLocator {
/**
* Locates a {@link JobConfiguration} at runtime.
*
* @param name the name of the {@link JobConfiguration} which should be
* unique
* @return a {@link JobConfiguration} identified by the given name
*
* @throws NoSuchJobConfigurationException if the required configuratio can
* not be found.
*/
JobConfiguration getJobConfiguration(String name) throws NoSuchJobConfigurationException;
}

View File

@@ -0,0 +1,44 @@
/*
* Copyright 2006-2007 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.batch.core.configuration;
/**
* A runtime service registry interface for registering job configurations by
* <code>name</code>.
*
* @author Dave Syer
*
*/
public interface JobConfigurationRegistry extends JobConfigurationLocator {
/**
* Registers a {@link JobConfiguration} at runtime.
*
* @param jobConfiguration the {@link JobConfiguration} to be registered
*
* @throws DuplicateJobConfigurationException if a configuration with the
* same name has already been registered.
*/
void register(JobConfiguration jobConfiguration) throws DuplicateJobConfigurationException;
/**
* Unregisters a previously registered {@link JobConfiguration}. If it was
* not previously registered there is no error.
*
* @param jobConfiguration the {@link JobConfiguration} to unregister.
*/
void unregister(JobConfiguration jobConfiguration);
}

View File

@@ -0,0 +1,36 @@
/*
* Copyright 2006-2007 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.batch.core.configuration;
import java.util.Collection;
/**
* A listable extension of {@link JobConfigurationRegistry}.
*
* @author Dave Syer
*
*/
public interface ListableJobConfigurationRegistry extends JobConfigurationRegistry {
/**
* Provides the currently registered configurations. The return value is
* unmodifiable and disconnected from the underlying registry storage.
*
* @return a collection of {@link JobConfiguration} instances. Empty if none
* are registered.
*/
Collection getJobConfigurations();
}

View File

@@ -0,0 +1,42 @@
/*
* Copyright 2006-2007 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.batch.core.configuration;
/**
* Checked exception to indicate that a required {@link JobConfiguration} is not
* available.
*
* @author Dave Syer
*
*/
public class NoSuchJobConfigurationException extends JobConfigurationException {
/**
* Create an exception with the given message.
*/
public NoSuchJobConfigurationException(String msg) {
super(msg);
}
/**
* @param msg The message to send to caller
* @param e the cause of the exception
*/
public NoSuchJobConfigurationException(String msg, Throwable e) {
super(msg, e);
}
}

View File

@@ -0,0 +1,60 @@
/*
* Copyright 2006-2007 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.batch.core.configuration;
import org.springframework.batch.core.tasklet.Tasklet;
/**
* Batch domain interface representing the configuration of a step. As with the
* (@link JobConfiguration), step configuration is meant to explicitly represent
* a the configuration of a step by a developer. This allows for the separation
* of what a developer configures from the myriad of concerns required for
* executing a job.
*
* @author Dave Syer
*
*/
public interface StepConfiguration {
/**
* @return the name of this step configuration.
*/
String getName();
/**
* @return the {@link Tasklet} instance to execute for each item processed.
*/
Tasklet getTasklet();
/**
* @return true if a step that is already marked as complete can be started
* again.
*/
boolean isAllowStartIfComplete();
/**
* Flag to indicate if restart data needs to be saved for this step.
* @return true if restart data should be saved
*/
boolean isSaveRestartData();
/**
* @return the number of times a job can be started with the same
* identifier.
*/
int getStartLimit();
}

View File

@@ -0,0 +1,151 @@
/*
* Copyright 2006-2007 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.batch.core.configuration;
import org.springframework.batch.core.tasklet.Tasklet;
import org.springframework.beans.factory.BeanNameAware;
/**
* Basic no-op support implementation for use as base class for
* {@link StepConfiguration}.
*
* @author Dave Syer
*
*/
public class StepConfigurationSupport implements StepConfiguration,
BeanNameAware {
private String name;
private int startLimit = Integer.MAX_VALUE;
private Tasklet tasklet;
private boolean allowStartIfComplete;
private boolean saveRestartData = false;
/**
* Default constructor for {@link StepConfigurationSupport}.
*/
public StepConfigurationSupport() {
super();
}
/**
* @param string
*/
public StepConfigurationSupport(String string) {
super();
this.name = string;
}
/*
* (non-Javadoc)
*
* @see org.springframework.batch.core.configuration.StepConfiguration#getName()
*/
public String getName() {
return this.name;
}
/**
* Set the name property if it is not already set. Because of the order of
* the callbacks in a Spring container the name property will be set first
* if it is present. Care is needed with bean definition inheritance - if a
* parent bean has a name, then its children need an explicit name as well,
* otherwise they will not be unique.
*
* @see org.springframework.beans.factory.BeanNameAware#setBeanName(java.lang.String)
*/
public void setBeanName(String name) {
if (this.name==null) {
this.name = name;
}
}
/**
* Set the name property. Always overrides the default value if this object
* is a Spring bean.
*
* @see #setBeanName(java.lang.String)
*/
public void setName(String name) {
this.name = name;
}
/*
* (non-Javadoc)
*
* @see org.springframework.batch.core.configuration.StepConfiguration#getStartLimit()
*/
public int getStartLimit() {
return this.startLimit;
}
/**
* Public setter for the startLimit.
*
* @param startLimit
* the startLimit to set
*/
public void setStartLimit(int startLimit) {
this.startLimit = startLimit;
}
/*
* (non-Javadoc)
*
* @see org.springframework.batch.core.configuration.StepConfiguration#getTasklet()
*/
public Tasklet getTasklet() {
return this.tasklet;
}
/**
* Public setter for the tasklet.
*
* @param tasklet
* the tasklet to set
*/
public void setTasklet(Tasklet tasklet) {
this.tasklet = tasklet;
}
/*
* (non-Javadoc)
*
* @see org.springframework.batch.core.configuration.StepConfiguration#shouldAllowStartIfComplete()
*/
public boolean isAllowStartIfComplete() {
return this.allowStartIfComplete;
}
/**
* Public setter for the shouldAllowStartIfComplete.
*
* @param allowStartIfComplete
* the shouldAllowStartIfComplete to set
*/
public void setAllowStartIfComplete(boolean allowStartIfComplete) {
this.allowStartIfComplete = allowStartIfComplete;
}
public void setSaveRestartData(boolean saveRestartData) {
this.saveRestartData = saveRestartData;
}
public boolean isSaveRestartData() {
return saveRestartData;
}
}

View File

@@ -0,0 +1,7 @@
<html>
<body>
<p>
Interfaces and generic implementations of configuration concerns.
</p>
</body>
</html>

View File

@@ -0,0 +1,62 @@
/*
* Copyright 2006-2007 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.batch.core.domain;
/**
* Typesafe enumeration representating the status of an artifact within
* the batch container. See Effective Java Programming by Joshua Bloch
* for more details on the pattern used.
*
* @author Lucas Ward
*
*/
public class BatchStatus {
private final String name;
private BatchStatus(String name) {
this.name = name;
}
public String toString(){
return name;
}
public static final BatchStatus COMPLETED = new BatchStatus("COMPLETED");
public static final BatchStatus STARTED = new BatchStatus("STARTED");
public static final BatchStatus STARTING = new BatchStatus("STARTING");
public static final BatchStatus FAILED = new BatchStatus("FAILED");
public static final BatchStatus STOPPED = new BatchStatus("STOPPED");
private static final BatchStatus[] VALUES = {STARTING, STARTED, COMPLETED, FAILED, STOPPED};
public static BatchStatus getStatus(String statusAsString){
for(int i = 0; i < VALUES.length; i++){
if(VALUES[i].toString().equals(statusAsString)){
return (BatchStatus)VALUES[i];
}
}
return null;
}
}

View File

@@ -0,0 +1,109 @@
/*
* Copyright 2006-2007 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.batch.core.domain;
import java.io.Serializable;
import org.springframework.util.ClassUtils;
/**
* Batch Domain Entity class. Any class that should be uniquely identifiable
* from another should subclass from Entity. More information on this pattern
* and the difference between Entities and Value Objects can be found in Domain
* Driven Design by Eric Evans.
*
* @author Lucas Ward
* @author Dave Syer
*
*/
public class Entity implements Serializable {
private Long id;
private Integer version;
public Entity() {
super();
}
public Entity(Long id) {
super();
this.id = id;
}
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
/**
* @return the version
*/
public Integer getVersion() {
return version;
}
// @Override
public String toString() {
return ClassUtils.getShortName(getClass()) + ": id=" + getId();
}
/**
* Attempt to establish identity based on id if both exist. If either id
* does not exist use Object.equals().
*
* @see java.lang.Object#equals(java.lang.Object)
*/
public boolean equals(Object other) {
if (other == this) {
return true;
}
if (other == null) {
return false;
}
if (!(other instanceof Entity)) {
return false;
}
Entity entity = (Entity) other;
if (id == null || entity.getId() == null) {
return entity == this;
}
return id.equals(entity.getId());
}
/**
* Use ID if it exists to establish hash code, otherwise fall back to
* Object.hashCode(). Based on the same information as equals, so if that
* changes, this will. N.B. this follows the contract of Object.hashCode(),
* but will cause problems for anyone adding an unsaved {@link Entity} to a
* Set because Set.contains() will almost certainly return false for the
* {@link Entity} after it is saved. Spring Batch does not store any of its
* entities in Sets as a matter of course, so internally this is consistent.
* Clients should not be exposed to unsaved entities.
*
* @see java.lang.Object#hashCode()
*/
public int hashCode() {
if (id == null) {
return super.hashCode();
}
return 39 + 87 * id.hashCode();
}
}

View File

@@ -0,0 +1,237 @@
/*
* Copyright 2006-2007 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.batch.core.domain;
import java.sql.Timestamp;
import java.util.Collection;
import java.util.HashSet;
import org.springframework.batch.repeat.ExitStatus;
import org.springframework.batch.repeat.RepeatContext;
/**
* Batch domain object representing the execution of a job.
*
* @author Lucas Ward
*
*/
public class JobExecution extends Entity {
private JobInstance job;
private transient Collection stepExecutions = new HashSet();
private transient Collection stepContexts = new HashSet();
private transient Collection chunkContexts = new HashSet();
private BatchStatus status = BatchStatus.STARTING;
private Timestamp startTime = new Timestamp(System.currentTimeMillis());
private Timestamp endTime = null;
private ExitStatus exitStatus = ExitStatus.UNKNOWN;
// Package private constructor for Hibernate
JobExecution() {
}
/**
* Because a JobExecution isn't valid unless the job is set, this
* constructor is the only valid one from a modelling point of view.
*
* @param job
* the job of which this execution is a part
*/
public JobExecution(JobInstance job, Long id) {
this.job = job;
setId(id);
}
/**
* Constructor for transient (unsaved) instances.
*
* @param job the enclosing {@link JobInstance}
*/
public JobExecution(JobInstance job) {
this(job, null);
}
public Timestamp getEndTime() {
return endTime;
}
public void setEndTime(Timestamp endTime) {
this.endTime = endTime;
}
public Timestamp getStartTime() {
return startTime;
}
public void setStartTime(Timestamp startTime) {
this.startTime = startTime;
}
public BatchStatus getStatus() {
return status;
}
public void setStatus(BatchStatus status) {
this.status = status;
}
/**
* Convenience getter for for the id of the enclosing job. Useful for DAO
* implementations.
*
* @return the id of the enclosing job
*/
public Long getJobId() {
if (job != null) {
return job.getId();
}
return null;
}
/**
* @param exitStatus
*/
public void setExitStatus(ExitStatus exitStatus) {
this.exitStatus = exitStatus;
}
/**
* @return the exitCode
*/
public ExitStatus getExitStatus() {
return exitStatus;
}
/**
* Accessor for the potentially multiple chunk contexts that are in
* progress. In a single-threaded, sequential execution there would normally
* be only one current chunk, but in more complicated scenarios there might
* be multiple active contexts.
*
* @return all the chunk contexts that have been registered and not
* unregistered. A collection of {@link RepeatContext} objects.
*/
public Collection getChunkContexts() {
synchronized (chunkContexts) {
return new HashSet(chunkContexts);
}
}
/**
* Accessor for the potentially multiple step contexts that are in progress.
* In a single-threaded, sequential execution there would normally be only
* one current step, but in more complicated scenarios there might be
* multiple active contexts.
*
* @return all the step contexts that have been registered and not
* unregistered. A collection of {@link RepeatContext} objects.
*/
public Collection getStepContexts() {
synchronized (stepContexts) {
return new HashSet(stepContexts);
}
}
/**
* Called at the start of a step, before any business logic is processed.
*
* @param context
* the current step context.
*/
public void registerStepContext(RepeatContext stepContext) {
synchronized (stepContexts) {
this.stepContexts.add(stepContext);
}
}
/**
* Called at the end of a step, after all business logic is processed, or in
* the case of a failure.
*
* @param context
* the current step context.
*/
public void unregisterStepContext(RepeatContext stepContext) {
synchronized (stepContexts) {
this.stepContexts.remove(stepContext);
}
}
/**
* Called at the start of a chunk, before any business logic is processed.
*
* @param context
* the current chunk context.
*/
public void registerChunkContext(RepeatContext chunkContext) {
synchronized (chunkContexts) {
this.chunkContexts.add(chunkContext);
}
}
/**
* Called at the end of a chunk, after all business logic is processed, or
* in the case of a failure.
*
* @param context
* the current chunk context.
*/
public void unregisterChunkContext(RepeatContext chunkContext) {
synchronized (chunkContexts) {
this.chunkContexts.remove(chunkContext);
}
}
/**
* @return the Job that is executing.
*/
public JobInstance getJob() {
return job;
}
/**
* Accessor for the step executions.
*
* @return the step executions that were registered
*/
public Collection getStepExecutions() {
return stepExecutions;
}
/**
* Register a step execution with the current job execution.
*
* @param stepExecution
*/
public void registerStepExecution(StepExecution stepExecution) {
this.stepExecutions.add(stepExecution);
}
/* (non-Javadoc)
* @see org.springframework.batch.core.domain.Entity#toString()
*/
public String toString() {
return super.toString()+", job=["+job+"]";
}
}

View File

@@ -0,0 +1,38 @@
/*
* Copyright 2006-2007 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.batch.core.domain;
/**
* Identifier strategy for {@link JobInstance}. Different batch projects can
* have different approaches and requirements regarding the identity of a job.
* The minimum requirement is to provide a unique name to identify a job. Other
* applications or projects might add other properties like a schedule date, or
* an additional label (code).
*
* @author Dave Syer
*
*/
public interface JobIdentifier {
/**
* A name property for jobs provided by the {@link JobIdentifier} strategy.
*
* @return the name of the job
*/
public String getName();
}

View File

@@ -0,0 +1,112 @@
/*
* Copyright 2006-2007 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.batch.core.domain;
import java.util.ArrayList;
import java.util.List;
/**
* Batch domain object representing a job instance. A job instance is defined as
* a logical container for steps with unique identification of the unit as a
* whole. A job can be executed many times with the same instance, usually if it
* fails and is restarted, or if it is launched on an ad-hoc basis "on demand".
*
* @author Lucas Ward
* @author Dave Syer
*/
public class JobInstance extends Entity {
private List steps = new ArrayList();
private JobIdentifier identifier;
// TODO declare transient or make the class serializable
private BatchStatus status;
private int jobExecutionCount;
/**
* Package private constructor for Hibernate use only
*/
JobInstance() {
this(null);
}
public JobInstance(JobIdentifier identifier, Long id) {
super();
setId(id);
this.identifier = identifier;
}
public JobInstance(JobIdentifier identifier) {
this(identifier, null);
}
public BatchStatus getStatus() {
return status;
}
public void setStatus(BatchStatus status) {
this.status = status;
}
public List getSteps() {
return steps;
}
public void setSteps(List steps) {
this.steps = steps;
}
public void addStep(StepInstance step) {
this.steps.add(step);
}
public int getJobExecutionCount() {
return jobExecutionCount;
}
public void setJobExecutionCount(int jobExecutionCount) {
this.jobExecutionCount = jobExecutionCount;
}
/**
* Public accessor for the identifier property.
*
* @return the identifier
*/
public JobIdentifier getIdentifier() {
return identifier;
}
/**
* @return the identifier name if there is one
*/
public String getName() {
return identifier==null ? null : identifier.getName();
}
public JobExecution createNewJobExecution() {
return new JobExecution(this);
}
public String toString() {
return super.toString()+", identifier=["+identifier+"]";
}
}

View File

@@ -0,0 +1,230 @@
/*
* Copyright 2006-2007 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.batch.core.domain;
import java.sql.Timestamp;
import java.util.Properties;
import org.springframework.batch.repeat.ExitStatus;
/**
* Batch domain object representation the execution of a step. Unlike
* JobExecution, there are four additional properties: luwCount, commitCount,
* rollbackCount and statistics. These values represent how many times a step
* has iterated through logical units of work, how many times it has been
* committed, and any other statistics the developer wishes to store,
* respectively.
*
* @author Lucas Ward
* @author Dave Syer
*
*/
public class StepExecution extends Entity {
private JobExecution jobExecution;
private StepInstance step;
private BatchStatus status = BatchStatus.STARTING;
private int taskCount = 0;
private int commitCount = 0;
private int rollbackCount = 0;
private Timestamp startTime = new Timestamp(System.currentTimeMillis());
private Timestamp endTime = null;
private Properties statistics = new Properties();
private ExitStatus exitStatus = ExitStatus.UNKNOWN;
/**
* Package private constructor for Hibernate
*/
StepExecution() {
super();
}
/**
* Constructor with mandatory properties.
*
* @param step the step to which this execution belongs
* @param jobExecution the current job execution
*/
public StepExecution(StepInstance step, JobExecution jobExecution, Long id) {
this();
this.step= step;
this.jobExecution = jobExecution;
setId(id);
}
public StepExecution(StepInstance step, JobExecution jobExecution) {
this(step, jobExecution, null);
}
public void incrementCommitCount() {
commitCount++;
}
public void incrementTaskCount() {
taskCount++;
}
public void incrementRollbackCount() {
rollbackCount++;
}
public Properties getStatistics() {
return statistics;
}
public void setStatistics(Properties statistics) {
this.statistics = statistics;
}
public Integer getCommitCount() {
return new Integer(commitCount);
}
public void setCommitCount(int commitCount) {
this.commitCount = commitCount;
}
public Timestamp getEndTime() {
return endTime;
}
public void setEndTime(Timestamp endTime) {
this.endTime = endTime;
}
public Integer getTaskCount() {
return new Integer(taskCount);
}
public void setTaskCount(int taskCount) {
this.taskCount = taskCount;
}
public void setRollbackCount(int rollbackCount) {
this.rollbackCount = rollbackCount;
}
public Integer getRollbackCount() {
return new Integer(rollbackCount);
}
public Timestamp getStartTime() {
return startTime;
}
public void setStartTime(Timestamp startTime) {
this.startTime = startTime;
}
public BatchStatus getStatus() {
return status;
}
public void setStatus(BatchStatus status) {
this.status = status;
}
public Long getStepId() {
if (step!=null) {
return step.getId();
}
return null;
}
/**
* Accessor for the job execution id.
* @return the jobExecutionId
*/
public Long getJobExecutionId() {
if (jobExecution!=null) {
return jobExecution.getId();
}
return null;
}
/* (non-Javadoc)
* @see org.springframework.batch.container.common.domain.Entity#equals(java.lang.Object)
*/
public boolean equals(Object obj) {
Object stepId = getStepId();
Object jobExecutionId = getJobExecutionId();
if (stepId==null && jobExecutionId==null || !(obj instanceof StepExecution) || getId()!=null) {
return super.equals(obj);
}
StepExecution other = (StepExecution) obj;
if (stepId==null) {
return jobExecutionId.equals(other.getJobExecutionId());
}
return stepId.equals(other.getStepId()) && (jobExecutionId==null || jobExecutionId.equals(other.getJobExecutionId()));
}
/* (non-Javadoc)
* @see org.springframework.batch.container.common.domain.Entity#hashCode()
*/
public int hashCode() {
Object stepId = getStepId();
Object jobExecutionId = getJobExecutionId();
return super.hashCode() + 31*(stepId!=null ? stepId.hashCode() : 0) + 91*(jobExecutionId!=null ? jobExecutionId.hashCode() : 0);
}
public String toString() {
return super.toString() + ", taskCount=" + taskCount + ", commitCount=" + commitCount + ", rollbackCount="
+ rollbackCount;
}
/**
* @param exitStatus
*/
public void setExitStatus(ExitStatus exitStatus) {
this.exitStatus = exitStatus;
}
/**
* @return the exitCode
*/
public ExitStatus getExitStatus() {
return exitStatus;
}
/**
* Accessor for the step governing this execution.
* @return the step
*/
public StepInstance getStep() {
return step;
}
/**
* Accessor for the execution context information of the enclosing job.
* @return the {@link jobExecutionContext} that was used to start this step
* execution.
*/
public JobExecution getJobExecution() {
return jobExecution;
}
}

View File

@@ -0,0 +1,124 @@
/*
* Copyright 2006-2007 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.batch.core.domain;
import java.util.Properties;
import org.springframework.batch.restart.GenericRestartData;
import org.springframework.batch.restart.RestartData;
/**
* <p>
* Batch domain entity representing a step which is sequentially executed by a
* job. Logically, steps are identified as a function of a job plus each step's
* name. For example, job 'TestJob' which has 2 steps: "TestStep1" and
* "TestStep2". The first step can be thought of as identified by
* "TestJob.TestStep1". In relational terms this may be represented by a foreign
* key on the Job's ID. Therefore, Each step instance is uniquely identified by
* it's ID, which is obtained from a JobRepository. Two steps with the same name
* and same job can be considered the same step.
* </p>
*
* <p>
* Because each step represents a runnable batch artifact with it's own
* lifecycle, each step contains status and an execution count. Status
* represents the status of each step's last execution (such as started,
* completed, failed, etc) and execution count is the count of executions for
* this individual step. It should be noted that a restartable job will create a
* new step instance (the same logical step, with a different ID) for every run.
* </p>
*
* @author Lucas Ward
* @author Dave Syer
*
*/
public class StepInstance extends Entity {
private JobInstance job;
// TODO declare transient or make serializable
private BatchStatus status;
private RestartData restartData = new GenericRestartData(new Properties());
private int stepExecutionCount = 0;
private String name;
/**
* Package private constructor for Hibernate only
*/
StepInstance() {
this(null);
}
public StepInstance(Long stepId) {
this(null, null, stepId);
}
public StepInstance(JobInstance job, String name) {
this(job, name, null);
}
public StepInstance(JobInstance job, String name, Long stepId) {
setId(stepId);
this.job = job;
this.name = name;
}
public int getStepExecutionCount() {
return stepExecutionCount;
}
public void setStepExecutionCount(int stepExecutionCount) {
this.stepExecutionCount = stepExecutionCount;
}
public RestartData getRestartData() {
return restartData;
}
public void setRestartData(RestartData restartData) {
this.restartData = restartData;
}
public BatchStatus getStatus() {
return status;
}
public void setStatus(BatchStatus status) {
this.status = status;
}
public JobInstance getJob() {
return job;
}
public String getName() {
return name;
}
public Long getJobId() {
return job==null ? null : job.getId();
}
// @Override
public String toString() {
return super.toString() + ", name=" + name + ", status=" + getStatus() + " in " + job;
}
}

View File

@@ -0,0 +1,7 @@
<html>
<body>
<p>
Interfaces and generic implementations of domain concerns.
</p>
</body>
</html>

View File

@@ -0,0 +1,43 @@
/*
* Copyright 2006-2007 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.batch.core.executor;
import org.springframework.batch.common.ExceptionClassifier;
import org.springframework.batch.repeat.ExitStatus;
/**
* Extension of the ExceptionClassifier that explicitly deals with
* returns an ExitStatus. This is useful for mapping from an exception
* type to an Exit Code with a detailed message.
*
* @author Lucas Ward
*
*/
public interface ExitCodeExceptionClassifier extends ExceptionClassifier {
static final String FATAL_EXCEPTION = "FATAL_EXCEPTION";
static final String STEP_INTERRUPTED = "STEP_INTERRUPTED";
/**
* Typesafe version of classify that explicitly returns an {@link ExitStatus}
* object.
*
* @param throwable
* @return ExitStatus representing the ExitCode and Message for the given
* exception.
*/
public ExitStatus classifyForExitCode(Throwable throwable);
}

View File

@@ -0,0 +1,31 @@
/*
* Copyright 2006-2007 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.batch.core.executor;
/**
* @author Dave Syer
*
*/
public class JobExecutionException extends Exception {
public JobExecutionException(String msg) {
super(msg);
}
public JobExecutionException(String msg, Throwable cause) {
super(msg, cause);
}
}

View File

@@ -0,0 +1,36 @@
/*
* Copyright 2006-2007 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.batch.core.executor;
import org.springframework.batch.core.configuration.JobConfiguration;
import org.springframework.batch.core.domain.JobExecution;
import org.springframework.batch.io.exception.BatchCriticalException;
import org.springframework.batch.repeat.ExitStatus;
/**
* Interface for running a job from its configuration.
*
* @author Lucas Ward
* @author Dave Syer
* @see JobConfiguration
* @see JobExecution
*/
public interface JobExecutor {
public ExitStatus run(JobConfiguration configuration, JobExecution execution) throws BatchCriticalException;
}

View File

@@ -0,0 +1,73 @@
/*
* Copyright 2006-2007 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.batch.core.executor;
import org.springframework.batch.core.configuration.StepConfiguration;
import org.springframework.batch.core.domain.StepExecution;
import org.springframework.batch.io.exception.BatchCriticalException;
import org.springframework.batch.repeat.ExitStatus;
/**
* Interface for processing a step. Implementations are free to process the step
* and return when finished, or to schedule the step for processing
* concurrently, or in the future. The status of the execution should be
* trackable with the step execution. The configuration should be treated as
* immutable.<br/>
*
* Because step execution parameters and policies can vary from step to step, a
* {@link StepExecutor} should be created by the caller using a
* {@link StepExecutorFactory}.
*
* @author Lucas Ward
* @author Dave Syer
*
*/
public interface StepExecutor {
/**
* Process the step according to the given configuration. Implementations
* can be expected to modify their state when this method is called, to take
* account of any policy information in the configuration. Thus it is not
* safe to re-use an instance of {@link StepExecutor} to process multiple
* concurrent executions.
*
* @param configuration
* the configuration to use when running the step. Contains a
* recipe for the business logic of an individual processing
* operation. Also used to determine policies for commit
* intervals and exception handling, for instance.
*
* @param stepExecution
* an entity representing the step to be executed
* @throws StepInterruptedException
* if the step is interrupted externally
* @throws BatchCriticalException
* if there is a problem that needs to be signalled to the
* caller
*/
ExitStatus process(StepConfiguration configuration,
StepExecution stepExecution) throws StepInterruptedException,
BatchCriticalException;
/**
* Apply the configuration by inspecting it to see if it has any relevant
* policy information. Should be called before any calls to process.
*
* @param configuration
*/
void applyConfiguration(StepConfiguration configuration);
}

View File

@@ -0,0 +1,44 @@
/*
* Copyright 2006-2007 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.batch.core.executor;
import org.springframework.batch.core.configuration.StepConfiguration;
/**
* Factory interface for creating or locating {@link StepExecutor} instances.
* Because step execution parameters and policies can vary from step to step, a
* {@link StepExecutor} should be created by the caller using a
* {@link StepExecutorFactory}. The factory is responsible for ensuring that
* the returned instance is appropriate for the configuration supplied. If the
* {@link StepExecutor} instance is stateful (which is normal) the factory
* should return a different instance for each call.
*
* @author Dave Syer
*
*/
public interface StepExecutorFactory {
/**
* Use the configuration given to create or locate a suitable
* {@link StepExecutor}.
*
* @param configuration a {@link StepConfiguration} instance.
* @return a {@link StepExecutor} that can be used to execute a step with
* the given configuration
*/
StepExecutor getExecutor(StepConfiguration configuration);
}

View File

@@ -0,0 +1,37 @@
/*
* Copyright 2006-2007 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.batch.core.executor;
import org.springframework.batch.io.exception.BatchCriticalException;
/**
* Exception to indicate the the lifecycle has been interrupted. The exception
* state indicated is not normally recoverable by batch application clients, but
* internally it is useful to force a check. The exception will be wrapped in a
* runtime exception (usually {@link BatchCriticalException} before reaching the
* client.
*
* @author Lucas Ward
* @author Dave Syer
*
*/
public class StepInterruptedException extends JobExecutionException {
public StepInterruptedException(String msg) {
super(msg);
}
}

View File

@@ -0,0 +1,7 @@
<html>
<body>
<p>
Interfaces and generic implementations of executor concerns.
</p>
</body>
</html>

View File

@@ -0,0 +1,11 @@
<html>
<body>
<p>
Core domain context for Spring Batch covering jobs, steps,
configuration and execution abstractions. Most classes here are
interfaces with implementations saved for specific applications. This
is the public API of Spring Batch. There is a reference
implementation of the core interfaces in the execution module.
</p>
</body>
</html>

View File

@@ -0,0 +1,41 @@
/*
* Copyright 2006-2007 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.batch.core.repository;
import org.springframework.batch.io.exception.BatchCriticalException;
/**
* @author Dave Syer
*
*/
public class BatchRestartException extends BatchCriticalException {
/**
* @param string the message
*/
public BatchRestartException(String string) {
super(string);
}
/**
* @param msg the cause
* @param t the message
*/
public BatchRestartException(String msg, Throwable t) {
super(msg, t);
}
}

View File

@@ -0,0 +1,118 @@
/*
* Copyright 2006-2007 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.batch.core.repository;
import org.springframework.batch.core.configuration.JobConfiguration;
import org.springframework.batch.core.domain.JobExecution;
import org.springframework.batch.core.domain.JobIdentifier;
import org.springframework.batch.core.domain.JobInstance;
import org.springframework.batch.core.domain.StepExecution;
import org.springframework.batch.core.domain.StepInstance;
/**
* <p>
* Repository for storing batch jobs and steps. Before using any methods, a Job
* must first be obtained using the findOrCreateJob method. Once a Job and it's
* related steps are obtained, they can be updated. It should be noted that any
* reconstituted steps are expected to contain restart data <strong>if the
* RestartPolicy associated with the step returns true, and RestartData exists.</strong>
* </p>
*
* Once a Job/Steps has been created, Job and Step executions can be created and
* associated with a job, by setting the JobId and StepId respectively. Once
* these Id's are set, an execution can be persisted. If the object is in a
* transient state (i.e. it has no id of it's own) then an ID will be created
* for that specific execution, and then stored ('saved'). (NOTE: The
* relationship between a Job/Step and Job/StepExecutions is 1:N) If an ID does
* exist, then the execution will be stored ('updated').
*
*
* @author Lucas Ward
*
*/
public interface JobRepository {
/**
* Find or create a job for a given {@link JobIdentifier} and configuration.
* If the job that is uniquely identified by {@link JobIdentifier} already
* exists, its persisted values (including ID) will be returned in a new
* {@link JobInstance} object. If no previous run is found, a new job will
* be created and returned.
*
* @param jobConfiguration
* describes the configuration for this job
* @param jobIdentifier
* identifies this particular run of the configuration across
* possible restarts
*
* @return a valid job
*
*/
public JobInstance findOrCreateJob(JobConfiguration jobConfiguration,
JobIdentifier jobIdentifier);
/**
* Update a Job.
*
* Preconditions: Job must contain a valid ID. This can be ensured by first
* obtaining a job from findOrCreateJob.
*
* @param job
* @see JobInstance
*/
public void update(JobInstance job);
/**
* Save or Update a {@link JobExecution}. If no ID is found a new instance
* will be saved. If an ID does exist it will be updated. The ID should only
* be assigned to a {@link JobExecution} by calling this method - it should
* be left blank on the first call, and assigned by the
* {@link JobRepository}.
*
* Preconditions: {@link JobExecution} must contain a valid
* {@link JobInstance}.
*
* @param jobInstance
*/
public void saveOrUpdate(JobExecution jobExecution);
/**
* Update a step.
*
* Preconditions: {@link StepInstance} must contain a valid ID. This can be
* ensured by first obtaining a {@link JobInstance} from findOrCreateJob,
* and accessing it's step list.
*
* @param step
* @see StepInstance
*/
public void update(StepInstance step);
/**
* Save or Update a StepExecution. If no ID is found a new instance will be
* created. (saved). If an ID does exist it will be updated. It is not
* advisable that an ID be assigned to a JobExecution before calling this
* method. Instead, it should be left blank, to be assigned by a
* JobRepository.
*
* Preconditions: StepExecution must have a valid StepId.
*
* @param jobInstance
*/
public void saveOrUpdate(StepExecution stepExecution);
}

View File

@@ -0,0 +1,34 @@
/*
* Copyright 2006-2007 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.batch.core.repository;
/**
* This exception identifies that a batch domain object is invalid, which
* is generally caused by an invalid ID. (An ID which doesn't exist in the database).
*
* @author Lucas Ward
* @author Dave Syer
*
*/
public class NoSuchBatchDomainObjectException extends RuntimeException {
private static final long serialVersionUID = 4399621765157283111L;
public NoSuchBatchDomainObjectException(String message){
super(message);
}
}

View File

@@ -0,0 +1,7 @@
<html>
<body>
<p>
Interfaces and generic implementations of repository concerns.
</p>
</body>
</html>

View File

@@ -0,0 +1,44 @@
/*
* Copyright 2006-2007 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.batch.core.runtime;
import org.springframework.batch.core.domain.JobIdentifier;
/**
* A factory for {@link JobIdentifier} instances. A job configuration can be
* executed with many possible runtime parameters, which identify the instance
* of the job. This factory allows job identifiers to be created with different
* properties according to the {@link JobIdentifier} strategy required. For
* example some projects or jobs need a schedule date as part of the
* {@link JobIdentifier} and some do not (e.g. for an ad-hoc execution a simple
* label might be enough).
*
*
* @author Dave Syer
*
*/
public interface JobIdentifierFactory {
/**
* Get a new {@link JobIdentifier} instance.
*
* @param name
* the name of the job configuration.
* @return a {@link JobIdentifier} with the same name.
*/
public JobIdentifier getJobIdentifier(String name);
}

View File

@@ -0,0 +1,76 @@
/*
* Copyright 2006-2007 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.batch.core.runtime;
import org.apache.commons.lang.builder.EqualsBuilder;
import org.apache.commons.lang.builder.HashCodeBuilder;
import org.springframework.batch.core.domain.JobIdentifier;
import org.springframework.util.ClassUtils;
/**
* @author Dave Syer
*
*/
public class SimpleJobIdentifier implements JobIdentifier {
private String name;
/**
* Default constructor.
*/
public SimpleJobIdentifier() {
super();
}
/**
* Convenience constructor with name.
* @param name
*/
public SimpleJobIdentifier(String name) {
super();
this.name = name;
}
/* (non-Javadoc)
* @see org.springframework.batch.core.runtime.JobIdentifier#getName()
*/
public String getName() {
return this.name;
}
/**
* Public setter for the name.
*
* @param name the name to set
*/
public void setName(String name) {
this.name = name;
}
public String toString() {
return ClassUtils.getShortName(getClass())+": name=" + name;
}
public boolean equals(Object obj) {
return EqualsBuilder.reflectionEquals(this, obj);
}
public int hashCode() {
return HashCodeBuilder.reflectionHashCode(this);
}
}

View File

@@ -0,0 +1,26 @@
package org.springframework.batch.core.runtime;
import org.springframework.batch.core.domain.JobIdentifier;
/**
* Factory for {@link SimpleJobIdentifier} instances.
*
* @author Dave Syer
*
*/
public class SimpleJobIdentifierFactory implements JobIdentifierFactory {
/**
* Create a {@link JobIdentifier} with the given name.
*
* @param name the name for the {@link JobIdentifier}
* @return a {@link JobIdentifier} with the given name.
*
* @see org.springframework.batch.core.runtime.JobIdentifierFactory#getJobIdentifier(java.lang.String)
*/
public JobIdentifier getJobIdentifier(String name) {
return new SimpleJobIdentifier(name);
}
}

View File

@@ -0,0 +1,7 @@
<html>
<body>
<p>
Interfaces and generic implementations of runtime concerns.
</p>
</body>
</html>

View File

@@ -0,0 +1,39 @@
/*
* Copyright 2006-2007 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.batch.core.tasklet;
/**
* Marker interface for {@link Tasklet} implementations that are able to take a
* recovery action in the case that an exception is thrown inside
* {@link Tasklet#execute()}. Containers must ensure that the recover method is
* called in a different transactional context than the failed execution, e.g.
* by creating a new transaction with propagation REQUIRES_NEW.
*
* @author Dave Syer
*
*/
public interface Recoverable {
/**
* Take some action to recover the current batch operation. E.g. send a
* message to an error queue, or append a bad record to a special file.
*
* @param cause the exception that caused the recovery step to be called.
*/
void recover(Throwable cause);
}

View File

@@ -0,0 +1,56 @@
/*
* Copyright 2006-2007 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.batch.core.tasklet;
import org.springframework.batch.core.configuration.StepConfiguration;
import org.springframework.batch.repeat.ExitStatus;
/**
* The primary interface describing the touch-point between the batch developer
* and a spring-batch execution. The execute method will be called to indicate
* to the developer that it is time to execute business logic. The value
* returned from this method will indicate whether or not processing should
* continue. It is important to note that in the vast majority of cases this
* class should not be directly implemented by batch developers for processing.
* Most batch processing is significantly more complex than simple execute and
* should logically be broken into a minimum of two processes (read and write).
* However, many architecture teams may find creating their own implementations
* of this interface useful for differentiating different batch job types, or
* for creating more flexibility within their batch jobs.
*
* @see StepConfiguration
* @author Lucas Ward
* @author Dave Syer
*
*/
public interface Tasklet {
/**
* Primary batch processing driver. All processing of batch business data
* should be handled within this method. Any processing which intends to
* control the flow of the batch lifecycle by throwing exceptions (such as
* BatchCriticalExeception) should throw them within this method. Doing so
* outside of this method will prevent the architecture from gracefully
* shutting down and providing such features as transaction rollback.
*
* @return ExitStatus indicating whether the processing should continue (i.e.
* false when data are exhausted).
* @see org.springframework.batch.repeat.ExitStatus
*/
public ExitStatus execute() throws Exception;
}

View File

@@ -0,0 +1,7 @@
<html>
<body>
<p>
Interfaces and generic implementations of tasklet concerns.
</p>
</body>
</html>

View File

@@ -0,0 +1,8 @@
<html>
<body>
<p>
The Core domain concepts expressed as interfaces and generic
implementations.
</p>
</body>
</html>

View File

@@ -0,0 +1,8 @@
Changelog: Spring Batch Core
* 1.0-M2
** 2007/07/12
* No-one uses this file: we should just switch to auto-generated changelogs?

View File

@@ -0,0 +1,60 @@
------
Simple Batch Execution Core
------
Dave Syer
------
August 2007
Overview of the Spring Batch Core Domain
The Spring Batch Core Domain consists of a public API for launching,
monitoring and managing batch jobs.
[images/core-domain-overview.png] The Spring Batch Core Domain with
dependencies to infrastructure indicated schematically.
The figure above shows the central parts of the core domain and its
main touch points with the batch application develepor
(<<<*Configuration>>>). To launch a job there is a
<<<JobExecutor>>> interface and a facade for it that can be used to
simplify the launching for dumb clients like JMX or a command line.
A <<<JobConfiguration>>> is composed of a list of
<<<StepConfiguration>>>s, each of which is executed in turn by the
<<<JobExecutor>>>, delegating to a <<<StepExecutor>>>. The
<<<StepExecutor>>> is a central strategy in the Spring Batch Core.
Implementations of <<<StepExecutor>>> are responsible for sharing
the work specified by the <<<StepConfiguration>>> out, but in ways
that the configuration doesn't need to be aware of. For instance,
the same <<<StepConfiguration>>> might be used in a simple
in-process sequential executor, or in a multi-threaded
implementation, or one that delegates to remote calls to a
distributed system.
[images/core-domain-extended.png] The Spring Batch Core Domain
extended to include the datababase entities and identifier strategy.
A <<<JobConfiguration>>> can be re-used to create multiple job
instances and this is reflected in the figure above showing an
extended picture of the core domain. When a <<<JobConfiguration>>>
is launched the <<<JobExecutor>>> first checks to see if a job with
the same <<<JobIdentifier>>> was already executed. We expect one of
the following outcomes, depending on the <<<JobExecutor>>>
implementation and <<<JobConfiguration>>>:
* If the job was not previously launched then it can be created
and executed. A new <<<JobInstance>>> is created and stored in a
repository (usually a database). A new <<<JobExecution>>> is also
created to track the progress of this particular execution.
* If the job was previously launched the <<<JobConfiguration>>>
has a flag indicating whether or not to continue and launch a new
execution (was this expected?). The decision is parameterised to
depend on whether or not the job failed last time it was executed.
If the there was a previous failure - maybe the operator has fixed
some bad input and wants to run it again - then we might want to
restart the previous job. Or it might be an ad-hoc request that
doesn't need to be distinguished from previous runs. In either
case a new <<<JobExecution>>> is created and stored to monitor
this execution of the <<<JobInstance>>>.

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.8 KiB

View File

@@ -0,0 +1,30 @@
<?xml version="1.0" encoding="ISO-8859-1"?>
<project name="Spring Batch: ${project.name}">
<bannerLeft>
<name>Spring Batch: ${project.name}</name>
</bannerLeft>
<bannerRight>
<src>images/shim.gif</src>
</bannerRight>
<poweredBy>
<logo name="" href="" img="images/shim.gif"/>
</poweredBy>
<skin>
<groupId>org.springframework.maven.skins</groupId>
<artifactId>maven-spring-skin</artifactId>
<version>1.0.4</version>
</skin>
<body>
<links>
<item name="Home" href="../index.html"/>
<item name="${project.name}" href="index.html"/>
</links>
<menu name="Spring Batch Core">
<item name="${project.name}" href="index.html"/>
</menu>
<menu ref="reports"/>
</body>
</project>

View File

@@ -0,0 +1,37 @@
/*
* Copyright 2006-2007 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.batch.core;
import junit.framework.TestCase;
public abstract class AbstractExceptionTests extends TestCase {
public void testExceptionString() throws Exception {
Exception exception = getException("foo");
assertEquals("foo", exception.getMessage());
}
public void testExceptionStringThrowable() throws Exception {
Exception exception = getException("foo", new IllegalStateException());
assertEquals("foo", exception.getMessage().substring(0, 3));
}
public abstract Exception getException(String msg) throws Exception;
public abstract Exception getException(String msg, Throwable t) throws Exception;
}

View File

@@ -0,0 +1,44 @@
/*
* Copyright 2006-2007 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.batch.core.configuration;
import org.springframework.batch.core.AbstractExceptionTests;
import org.springframework.batch.core.configuration.DuplicateJobConfigurationException;
/**
* @author Dave Syer
*
*/
public class DuplicateJobConfigurationExceptionTests extends AbstractExceptionTests {
/*
* (non-Javadoc)
* @see org.springframework.batch.io.exception.AbstractExceptionTests#getException(java.lang.String)
*/
public Exception getException(String msg) throws Exception {
return new DuplicateJobConfigurationException(msg);
}
/*
* (non-Javadoc)
* @see org.springframework.batch.io.exception.AbstractExceptionTests#getException(java.lang.String,
* java.lang.Throwable)
*/
public Exception getException(String msg, Throwable t) throws Exception {
return new DuplicateJobConfigurationException(msg, t);
}
}

View File

@@ -0,0 +1,44 @@
/*
* Copyright 2006-2007 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.batch.core.configuration;
import org.springframework.batch.core.AbstractExceptionTests;
import org.springframework.batch.core.configuration.JobConfigurationException;
/**
* @author Dave Syer
*
*/
public class JobConfigurationExceptionTests extends AbstractExceptionTests {
/*
* (non-Javadoc)
* @see org.springframework.batch.io.exception.AbstractExceptionTests#getException(java.lang.String)
*/
public Exception getException(String msg) throws Exception {
return new JobConfigurationException(msg);
}
/*
* (non-Javadoc)
* @see org.springframework.batch.io.exception.AbstractExceptionTests#getException(java.lang.String,
* java.lang.Throwable)
*/
public Exception getException(String msg, Throwable t) throws Exception {
return new JobConfigurationException(msg, t);
}
}

View File

@@ -0,0 +1,97 @@
/*
* Copyright 2006-2007 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.batch.core.configuration;
import java.util.Collections;
import junit.framework.TestCase;
/**
* @author Dave Syer
*
*/
public class JobConfigurationTests extends TestCase {
JobConfiguration configuration = new JobConfiguration("job");
/**
* Test method for
* {@link org.springframework.batch.core.configuration.JobConfiguration#JobConfiguration()}.
*/
public void testJobConfiguration() {
configuration = new JobConfiguration();
assertNull(configuration.getName());
}
/**
* Test method for
* {@link org.springframework.batch.core.configuration.JobConfiguration#setBeanName(java.lang.String)}.
*/
public void testSetBeanName() {
configuration.setBeanName("foo");
assertEquals("job", configuration.getName());
}
/**
* Test method for
* {@link org.springframework.batch.core.configuration.JobConfiguration#setBeanName(java.lang.String)}.
*/
public void testSetBeanNameWithNullName() {
configuration = new JobConfiguration(null);
assertEquals(null, configuration.getName());
configuration.setBeanName("foo");
assertEquals("foo", configuration.getName());
}
/**
* Test method for
* {@link org.springframework.batch.core.configuration.JobConfiguration#setSteps(java.util.List)}.
*/
public void testSetSteps() {
configuration.setSteps(Collections.singletonList(new StepConfigurationSupport("step")));
assertEquals(1, configuration.getStepConfigurations().size());
}
/**
* Test method for
* {@link org.springframework.batch.core.configuration.JobConfiguration#addStep(org.springframework.batch.core.configuration.StepConfiguration)}.
*/
public void testAddStep() {
configuration.addStep(new StepConfigurationSupport("step"));
assertEquals(1, configuration.getStepConfigurations().size());
}
/**
* Test method for
* {@link org.springframework.batch.core.configuration.JobConfiguration#setStartLimit(int)}.
*/
public void testSetStartLimit() {
assertEquals(Integer.MAX_VALUE, configuration.getStartLimit());
configuration.setStartLimit(10);
assertEquals(10, configuration.getStartLimit());
}
/**
* Test method for
* {@link org.springframework.batch.core.configuration.JobConfiguration#setRestartable(boolean)}.
*/
public void testSetRestartable() {
assertFalse(configuration.isRestartable());
configuration.setRestartable(true);
assertTrue(configuration.isRestartable());
}
}

View File

@@ -0,0 +1,44 @@
/*
* Copyright 2006-2007 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.batch.core.configuration;
import org.springframework.batch.core.AbstractExceptionTests;
import org.springframework.batch.core.configuration.NoSuchJobConfigurationException;
/**
* @author Dave Syer
*
*/
public class NoSuchJobConfigurationExceptionTests extends AbstractExceptionTests {
/*
* (non-Javadoc)
* @see org.springframework.batch.io.exception.AbstractExceptionTests#getException(java.lang.String)
*/
public Exception getException(String msg) throws Exception {
return new NoSuchJobConfigurationException(msg);
}
/*
* (non-Javadoc)
* @see org.springframework.batch.io.exception.AbstractExceptionTests#getException(java.lang.String,
* java.lang.Throwable)
*/
public Exception getException(String msg, Throwable t) throws Exception {
return new NoSuchJobConfigurationException(msg, t);
}
}

View File

@@ -0,0 +1,71 @@
/*
* Copyright 2006-2007 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.batch.core.configuration;
import junit.framework.TestCase;
import org.springframework.beans.factory.config.ConstructorArgumentValues;
import org.springframework.beans.factory.support.ChildBeanDefinition;
import org.springframework.beans.factory.support.RootBeanDefinition;
import org.springframework.context.support.GenericApplicationContext;
import org.springframework.context.support.StaticApplicationContext;
public class SpringBeanJobConfigurationTests extends TestCase {
public void testBeanName() throws Exception {
StaticApplicationContext context = new StaticApplicationContext();
JobConfiguration configuration = new JobConfiguration();
context.getAutowireCapableBeanFactory().initializeBean(configuration,
"bean");
assertNotNull(configuration.getName());
configuration.setBeanName("foo");
context.getAutowireCapableBeanFactory().initializeBean(configuration,
"bean");
assertEquals("bean", configuration.getName());
}
public void testBeanNameWithBeanDefinition() throws Exception {
GenericApplicationContext context = new GenericApplicationContext();
ConstructorArgumentValues args = new ConstructorArgumentValues();
args.addGenericArgumentValue("foo");
context.registerBeanDefinition("bean", new RootBeanDefinition(
JobConfiguration.class, args, null));
JobConfiguration configuration = (JobConfiguration) context
.getBean("bean");
assertNotNull(configuration.getName());
assertEquals("foo", configuration.getName());
configuration.setBeanName("bar");
assertEquals("foo", configuration.getName());
}
public void testBeanNameWithParentBeanDefinition() throws Exception {
GenericApplicationContext context = new GenericApplicationContext();
ConstructorArgumentValues args = new ConstructorArgumentValues();
args.addGenericArgumentValue("bar");
context.registerBeanDefinition("parent", new RootBeanDefinition(
JobConfiguration.class, args, null));
context.registerBeanDefinition("bean", new ChildBeanDefinition("parent"));
JobConfiguration configuration = (JobConfiguration) context
.getBean("bean");
assertNotNull(configuration.getName());
assertEquals("bar", configuration.getName());
configuration.setBeanName("foo");
assertEquals("bar", configuration.getName());
configuration.setName("foo");
assertEquals("foo", configuration.getName());
}
}

View File

@@ -0,0 +1,78 @@
/*
* Copyright 2006-2007 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.batch.core.configuration;
import junit.framework.TestCase;
import org.springframework.batch.core.tasklet.Tasklet;
import org.springframework.batch.repeat.ExitStatus;
/**
* @author Dave Syer
*
*/
public class StepConfigurationSupportTests extends TestCase {
private StepConfigurationSupport configuration = new StepConfigurationSupport("step");
/**
* Test method for {@link org.springframework.batch.core.configuration.StepConfigurationSupport#StepConfigurationSupport()}.
*/
public void testStepConfigurationSupport() {
configuration = new StepConfigurationSupport();
assertNull(configuration.getName());
}
/**
* Test method for {@link org.springframework.batch.core.configuration.StepConfigurationSupport#getName()}.
*/
public void testGetName() {
assertEquals("step", configuration.getName());
}
/**
* Test method for {@link org.springframework.batch.core.configuration.StepConfigurationSupport#getStartLimit()}.
*/
public void testGetStartLimit() {
assertEquals(Integer.MAX_VALUE, configuration.getStartLimit());
configuration.setStartLimit(10);
assertEquals(10, configuration.getStartLimit());
}
/**
* Test method for {@link org.springframework.batch.core.configuration.StepConfigurationSupport#getTasklet()}.
*/
public void testGetTasklet() {
assertEquals(null, configuration.getTasklet());
Tasklet tasklet = new Tasklet() {
public ExitStatus execute() throws Exception {
return ExitStatus.FINISHED;
}
};
configuration.setTasklet(tasklet);
assertEquals(tasklet, configuration.getTasklet());
}
/**
* Test method for {@link org.springframework.batch.core.configuration.StepConfigurationSupport#isAllowStartIfComplete()}.
*/
public void testShouldAllowStartIfComplete() {
assertEquals(false, configuration.isAllowStartIfComplete());
configuration.setAllowStartIfComplete(true);
assertEquals(true, configuration.isAllowStartIfComplete());
}
}

View File

@@ -0,0 +1,46 @@
/*
* Copyright 2006-2007 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.batch.core.domain;
import junit.framework.TestCase;
/**
* @author Dave Syer
*
*/
public class BatchStatusTests extends TestCase {
/**
* Test method for {@link org.springframework.batch.core.domain.BatchStatus#toString()}.
*/
public void testToString() {
assertEquals("FAILED", BatchStatus.FAILED.toString());
}
/**
* Test method for {@link org.springframework.batch.core.domain.BatchStatus#getStatus(java.lang.String)}.
*/
public void testGetStatus() {
assertEquals(BatchStatus.FAILED, BatchStatus.getStatus(BatchStatus.FAILED.toString()));
}
/**
* Test method for {@link org.springframework.batch.core.domain.BatchStatus#getStatus(java.lang.String)}.
*/
public void testGetStatusWrongCode() {
assertEquals(null, BatchStatus.getStatus("foo"));
}
}

View File

@@ -0,0 +1,111 @@
/*
* Copyright 2006-2007 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.batch.core.domain;
import junit.framework.TestCase;
/**
* @author Dave Syer
*
*/
public class EntityTests extends TestCase {
Entity entity = new Entity(new Long(11));
/**
* Test method for {@link org.springframework.batch.core.domain.Entity#hashCode()}.
*/
public void testHashCode() {
assertEquals(entity.hashCode(), new Entity(entity.getId()).hashCode());
}
/**
* Test method for {@link org.springframework.batch.core.domain.Entity#hashCode()}.
*/
public void testHashCodeNullId() {
int withoutNull = entity.hashCode();
entity.setId(null);
int withNull = entity.hashCode();
assertTrue(withoutNull!=withNull);
}
/**
* Test method for {@link org.springframework.batch.core.domain.Entity#getVersion()}.
*/
public void testGetVersion() {
assertEquals(null, entity.getVersion());
}
/**
* @throws Exception
*/
public void testToString() throws Exception {
Entity job = new Entity();
assertTrue(job.toString().indexOf("id=null") >= 0);
}
/**
* Test method for {@link org.springframework.batch.core.domain.Entity#equals(java.lang.Object)}.
*/
public void testEqualsSelf() {
assertEquals(entity, entity);
}
/**
* Test method for {@link org.springframework.batch.core.domain.Entity#equals(java.lang.Object)}.
*/
public void testEqualsSelfWithNullId() {
entity = new Entity(null);
assertEquals(entity, entity);
}
/**
* Test method for {@link org.springframework.batch.core.domain.Entity#equals(java.lang.Object)}.
*/
public void testEqualsEntityWithNullId() {
entity = new Entity(null);
assertNotSame(entity, new Entity(null));
}
/**
* Test method for {@link org.springframework.batch.core.domain.Entity#equals(java.lang.Object)}.
*/
public void testEqualsEntity() {
assertEquals(entity, new Entity(entity.getId()));
}
/**
* Test method for {@link org.springframework.batch.core.domain.Entity#equals(java.lang.Object)}.
*/
public void testEqualsEntityWrongId() {
assertFalse(entity.equals(new Entity()));
}
/**
* Test method for {@link org.springframework.batch.core.domain.Entity#equals(java.lang.Object)}.
*/
public void testEqualsObject() {
assertFalse(entity.equals(new Object()));
}
/**
* Test method for {@link org.springframework.batch.core.domain.Entity#equals(java.lang.Object)}.
*/
public void testEqualsNull() {
assertFalse(entity.equals(null));
}
}

View File

@@ -0,0 +1,150 @@
/*
* Copyright 2006-2007 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.batch.core.domain;
import java.sql.Timestamp;
import junit.framework.TestCase;
import org.springframework.batch.core.runtime.SimpleJobIdentifier;
import org.springframework.batch.repeat.ExitStatus;
import org.springframework.batch.repeat.context.RepeatContextSupport;
/**
* @author Dave Syer
*
*/
public class JobExecutionTests extends TestCase {
private JobExecution execution = new JobExecution(new JobInstance(null, new Long(11)));
private JobExecution context = new JobExecution(new JobInstance(new SimpleJobIdentifier("foo"), new Long(11)));
/**
* Test method for {@link org.springframework.batch.core.domain.JobExecution#JobExecution()}.
*/
public void testJobExecution() {
assertNull(new JobExecution().getId());
}
/**
* Test method for {@link org.springframework.batch.core.domain.JobExecution#getEndTime()}.
*/
public void testGetEndTime() {
assertNull(execution.getEndTime());
execution.setEndTime(new Timestamp(100L));
assertEquals(100L, execution.getEndTime().getTime());
}
/**
* Test method for {@link org.springframework.batch.core.domain.JobExecution#getStartTime()}.
*/
public void testGetStartTime() {
assertNotNull(execution.getStartTime());
execution.setStartTime(new Timestamp(0L));
assertEquals(0L, execution.getStartTime().getTime());
}
/**
* Test method for {@link org.springframework.batch.core.domain.JobExecution#getStatus()}.
*/
public void testGetStatus() {
assertEquals(BatchStatus.STARTING, execution.getStatus());
execution.setStatus(BatchStatus.COMPLETED);
assertEquals(BatchStatus.COMPLETED, execution.getStatus());
}
/**
* Test method for {@link org.springframework.batch.core.domain.JobExecution#getJobId()}.
*/
public void testGetJobId() {
assertEquals(11, execution.getJobId().longValue());
execution = new JobExecution(new JobInstance(null, new Long(23)));
assertEquals(23, execution.getJobId().longValue());
}
/**
* Test method for {@link org.springframework.batch.core.domain.JobExecution#getJobId()}.
*/
public void testGetJobIdForNullJob() {
execution = new JobExecution(null);
assertEquals(null, execution.getJobId());
}
/**
* Test method for {@link org.springframework.batch.core.domain.JobExecution#getJobId()}.
*/
public void testGetJob() {
assertNotNull(execution.getJob());
}
/**
* Test method for {@link org.springframework.batch.core.domain.JobExecution#getExitStatus()}.
*/
public void testGetExitCode() {
assertEquals(ExitStatus.UNKNOWN, execution.getExitStatus());
execution.setExitStatus(new ExitStatus(true, "23"));
assertEquals("23", execution.getExitStatus().getExitCode());
}
public void testContextContainsInfo() throws Exception {
assertEquals("foo", context.getJob().getIdentifier().getName());
}
public void testNullContexts() throws Exception {
assertEquals(0, context.getStepContexts().size());
assertEquals(0, context.getChunkContexts().size());
}
public void testStepContext() throws Exception {
context.registerStepContext(new RepeatContextSupport(null));
assertEquals(1, context.getStepContexts().size());
}
public void testAddAndRemoveStepContext() throws Exception {
context.registerStepContext(new RepeatContextSupport(null));
assertEquals(1, context.getStepContexts().size());
context.unregisterStepContext(new RepeatContextSupport(null));
assertEquals(0, context.getStepContexts().size());
}
public void testAddAndRemoveStepExecution() throws Exception {
assertEquals(0, context.getStepExecutions().size());
context.registerStepExecution(new StepExecution(null, null));
assertEquals(1, context.getStepExecutions().size());
}
public void testAddAndRemoveChunkContext() throws Exception {
context.registerChunkContext(new RepeatContextSupport(null));
assertEquals(1, context.getChunkContexts().size());
context.unregisterChunkContext(new RepeatContextSupport(null));
assertEquals(0, context.getChunkContexts().size());
}
public void testRemoveChunkContext() throws Exception {
context.unregisterChunkContext(new RepeatContextSupport(null));
assertEquals(0, context.getChunkContexts().size());
}
public void testToString() throws Exception {
assertTrue("JobExecution string does not contain id", context.toString().indexOf("id=")>=0);
assertTrue("JobExecution string does not contain name: "+context, context.toString().indexOf("foo")>=0);
}
public void testToStringWithNullJob() throws Exception {
context = new JobExecution();
assertTrue("JobExecution string does not contain id", context.toString().indexOf("id=")>=0);
}
}

View File

@@ -0,0 +1,93 @@
/*
* Copyright 2006-2007 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.batch.core.domain;
import java.util.Collections;
import org.springframework.batch.core.runtime.SimpleJobIdentifier;
import junit.framework.TestCase;
/**
* @author dsyer
*
*/
public class JobInstanceTests extends TestCase {
private JobInstance instance = new JobInstance(null, new Long(11));
/**
* Test method for {@link org.springframework.batch.core.domain.JobInstance#JobInstance()}.
*/
public void testJobInstance() {
assertNull(new JobInstance(null).getId());
}
/**
* Test method for {@link org.springframework.batch.core.domain.JobInstance#getStatus()}.
*/
public void testGetStatus() {
assertNull(instance.getStatus());
instance.setStatus(BatchStatus.COMPLETED);
assertNotNull(instance.getStatus());
}
/**
* Test method for {@link org.springframework.batch.core.domain.JobInstance#getSteps()}.
*/
public void testGetSteps() {
assertEquals(0, instance.getSteps().size());
instance.setSteps(Collections.singletonList(new StepInstance()));
assertEquals(1, instance.getSteps().size());
}
/**
* Test method for {@link org.springframework.batch.core.domain.JobInstance#addStep(org.springframework.batch.core.domain.StepInstance)}.
*/
public void testAddStep() {
instance.addStep(new StepInstance());
assertEquals(1, instance.getSteps().size());
}
/**
* Test method for {@link org.springframework.batch.core.domain.JobInstance#getJobExecutionCount()}.
*/
public void testGetJobExecutionCount() {
assertEquals(0, instance.getJobExecutionCount());
instance.setJobExecutionCount(22);
assertEquals(22, instance.getJobExecutionCount());
}
/**
* Test method for {@link org.springframework.batch.core.domain.JobInstance#getIdentifier()}.
*/
public void testGetIdentifier() {
assertEquals(null, instance.getIdentifier());
instance = new JobInstance(new SimpleJobIdentifier("foo"));
assertEquals("foo", instance.getIdentifier().getName());
}
/**
* Test method for {@link org.springframework.batch.core.domain.JobInstance#getIdentifier()}.
*/
public void testGetName() {
assertEquals(null, instance.getName());
instance = new JobInstance(new SimpleJobIdentifier("foo"));
assertEquals("foo", instance.getName());
}
}

View File

@@ -0,0 +1,220 @@
/*
* Copyright 2006-2007 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.batch.core.domain;
import java.sql.Timestamp;
import java.util.Properties;
import org.springframework.batch.repeat.ExitStatus;
import junit.framework.TestCase;
/**
* @author Dave Syer
*
*/
public class StepExecutionTests extends TestCase {
private StepExecution execution = newStepExecution(new Long(11),
new Long(23));
/**
* Test method for
* {@link org.springframework.batch.core.domain.JobExecution#JobExecution()}.
*/
public void testStepExecution() {
assertNull(new StepExecution().getId());
}
/**
* Test method for
* {@link org.springframework.batch.core.domain.JobExecution#getEndTime()}.
*/
public void testGetEndTime() {
assertNull(execution.getEndTime());
execution.setEndTime(new Timestamp(0L));
assertEquals(0L, execution.getEndTime().getTime());
}
/**
* Test method for
* {@link org.springframework.batch.core.domain.JobExecution#getStartTime()}.
*/
public void testGetStartTime() {
assertNotNull(execution.getStartTime());
execution.setStartTime(new Timestamp(10L));
assertEquals(10L, execution.getStartTime().getTime());
}
/**
* Test method for
* {@link org.springframework.batch.core.domain.JobExecution#getStatus()}.
*/
public void testGetStatus() {
assertEquals(BatchStatus.STARTING, execution.getStatus());
execution.setStatus(BatchStatus.COMPLETED);
assertEquals(BatchStatus.COMPLETED, execution.getStatus());
}
/**
* Test method for
* {@link org.springframework.batch.core.domain.JobExecution#getJobId()}.
*/
public void testGetJobId() {
assertEquals(23, execution.getJobExecutionId().longValue());
}
/**
* Test method for
* {@link org.springframework.batch.core.domain.JobExecution#getExitStatus()}.
*/
public void testGetExitCode() {
assertEquals(ExitStatus.UNKNOWN, execution.getExitStatus());
execution.setExitStatus(ExitStatus.FINISHED);
assertEquals(ExitStatus.FINISHED, execution.getExitStatus());
}
/**
* Test method for
* {@link org.springframework.batch.core.domain.StepExecution#incrementCommitCount()}.
*/
public void testIncrementCommitCount() {
int before = execution.getCommitCount().intValue();
execution.incrementCommitCount();
int after = execution.getCommitCount().intValue();
assertEquals(before + 1, after);
}
/**
* Test method for
* {@link org.springframework.batch.core.domain.StepExecution#incrementTaskCount()}.
*/
public void testIncrementLuwCount() {
int before = execution.getTaskCount().intValue();
execution.incrementTaskCount();
int after = execution.getTaskCount().intValue();
assertEquals(before + 1, after);
}
/**
* Test method for
* {@link org.springframework.batch.core.domain.StepExecution#incrementRollbackCount()}.
*/
public void testIncrementRollbackCount() {
int before = execution.getRollbackCount().intValue();
execution.incrementRollbackCount();
int after = execution.getRollbackCount().intValue();
assertEquals(before + 1, after);
}
/**
* Test method for
* {@link org.springframework.batch.core.domain.StepExecution#getCommitCount()}.
*/
public void testGetCommitCount() {
execution.setCommitCount(123);
assertEquals(123, execution.getCommitCount().intValue());
}
/**
* Test method for
* {@link org.springframework.batch.core.domain.StepExecution#getTaskCount()}.
*/
public void testGetTaskCount() {
execution.setTaskCount(123);
assertEquals(123, execution.getTaskCount().intValue());
}
/**
* Test method for
* {@link org.springframework.batch.core.domain.StepExecution#getRollbackCount()}.
*/
public void testGetRollbackCount() {
execution.setRollbackCount(123);
assertEquals(123, execution.getRollbackCount().intValue());
}
/**
* Test method for
* {@link org.springframework.batch.core.domain.StepExecution#getStepId()}.
*/
public void testGetStepId() {
assertEquals(11, execution.getStepId().longValue());
}
public void testToString() throws Exception {
assertTrue("Should contain task count: " + execution.toString(),
execution.toString().indexOf("task") >= 0);
assertTrue("Should contain commit count: " + execution.toString(),
execution.toString().indexOf("commit") >= 0);
assertTrue("Should contain rollback count: " + execution.toString(),
execution.toString().indexOf("rollback") >= 0);
}
public void testStatistics() throws Exception {
assertNotNull(execution.getStatistics());
execution.setStatistics(new Properties() {
{
setProperty("foo", "bar");
}
});
assertEquals("bar", execution.getStatistics().getProperty("foo"));
}
public void testEqualsWithSameIdentifier() throws Exception {
StepExecution step1 = newStepExecution(new Long(100), new Long(11));
StepExecution step2 = newStepExecution(new Long(100), new Long(11));
assertEquals(step1, step2);
}
public void testEqualsWithNull() throws Exception {
StepExecution step = newStepExecution(new Long(100), new Long(11));
assertFalse(step.equals(null));
}
public void testEqualsWithNullIdentifiers() throws Exception {
StepExecution step = newStepExecution(new Long(100), new Long(11));
assertFalse(step.equals(new StepExecution()));
}
public void testEqualsWithNullJob() throws Exception {
StepExecution step = newStepExecution(null, new Long(11));
assertFalse(step.equals(new StepExecution()));
}
public void testEqualsWithNullStep() throws Exception {
StepExecution step = newStepExecution(new Long(11), null);
assertFalse(step.equals(new StepExecution()));
}
public void testHashCode() throws Exception {
assertTrue("Hash code same as parent", new Entity(execution.getId())
.hashCode() != execution.hashCode());
}
public void testHashCodeWithNullIds() throws Exception {
assertTrue("Hash code not same as parent",
new Entity(execution.getId()).hashCode() != new StepExecution()
.hashCode());
}
private StepExecution newStepExecution(Long long1, Long long2) {
JobInstance job = new JobInstance(null);
StepInstance step = new StepInstance(job, "foo", long1);
StepExecution execution = new StepExecution(step, new JobExecution(job, long2));
return execution;
}
}

View File

@@ -0,0 +1,109 @@
/*
* Copyright 2006-2007 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.batch.core.domain;
import java.util.Properties;
import org.springframework.batch.restart.GenericRestartData;
import junit.framework.TestCase;
/**
* @author Dave Syer
*
*/
public class StepInstanceTests extends TestCase {
StepInstance instance = new StepInstance(new Long(13));
/**
* Test method for {@link org.springframework.batch.core.domain.StepInstance#StepInstance()}.
*/
public void testStepInstance() {
assertNull(new StepInstance().getId());
}
/**
* Test method for {@link org.springframework.batch.core.domain.StepInstance#getStepExecutionCount()}.
*/
public void testGetStepExecutionCount() {
assertEquals(0, instance.getStepExecutionCount());
instance.setStepExecutionCount(23);
assertEquals(23, instance.getStepExecutionCount());
}
/**
* Test method for {@link org.springframework.batch.core.domain.StepInstance#getRestartData()}.
*/
public void testGetRestartData() {
assertNotNull(instance.getRestartData());
assertTrue(instance.getRestartData().getProperties().isEmpty());
instance.setRestartData(new GenericRestartData(new Properties() {{
setProperty("foo", "bar");
}}));
assertEquals("bar", instance.getRestartData().getProperties().getProperty("foo"));
}
/**
* Test method for {@link org.springframework.batch.core.domain.StepInstance#getStatus()}.
*/
public void testGetStatus() {
assertEquals(null, instance.getStatus());
instance.setStatus(BatchStatus.COMPLETED);
assertEquals(BatchStatus.COMPLETED, instance.getStatus());
}
/**
* Test method for {@link org.springframework.batch.core.domain.StepInstance#getJob()}.
*/
public void testGetJob() {
assertEquals(null, instance.getJob());
JobInstance job = new JobInstance(null);
instance = new StepInstance(job, null);
assertEquals(job, instance.getJob());
}
/**
* Test method for {@link org.springframework.batch.core.domain.StepInstance#getName()}.
*/
public void testGetName() {
assertEquals(null, instance.getName());
instance = new StepInstance(null, "foo");
assertEquals("foo", instance.getName());
}
/**
* Test method for {@link org.springframework.batch.core.domain.StepInstance#getJobId()}.
*/
public void testGetJobId() {
assertEquals(null, instance.getJobId());
instance = new StepInstance(new JobInstance(null, new Long(23)), null);
assertEquals(23, instance.getJobId().longValue());
}
public void testEqualsWithSameIdentifier() throws Exception {
JobInstance job = new JobInstance(null, new Long(100));
StepInstance step1 = new StepInstance(job, "foo", new Long(0));
StepInstance step2 = new StepInstance(job, "foo", new Long(0));
assertEquals(step1, step2);
}
public void testToString() throws Exception {
assertTrue("Should contain name", instance.toString().indexOf("name=")>=0);
assertTrue("Should contain status", instance.toString().indexOf("status=")>=0);
}
}

View File

@@ -0,0 +1,40 @@
/*
* Copyright 2006-2007 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.batch.core.executor;
import org.springframework.batch.core.AbstractExceptionTests;
/**
* @author Dave Syer
*
*/
public class JobExecutionExceptionTests extends AbstractExceptionTests {
/* (non-Javadoc)
* @see org.springframework.batch.io.exception.AbstractExceptionTests#getException(java.lang.String)
*/
public Exception getException(String msg) throws Exception {
return new JobExecutionException(msg);
}
/* (non-Javadoc)
* @see org.springframework.batch.io.exception.AbstractExceptionTests#getException(java.lang.String, java.lang.Throwable)
*/
public Exception getException(String msg, Throwable t) throws Exception {
return new JobExecutionException(msg, t);
}
}

View File

@@ -0,0 +1,40 @@
/*
* Copyright 2006-2007 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.batch.core.executor;
import org.springframework.batch.core.AbstractExceptionTests;
/**
* @author Dave Syer
*
*/
public class StepInterruptedExceptionTests extends AbstractExceptionTests {
/* (non-Javadoc)
* @see org.springframework.batch.io.exception.AbstractExceptionTests#getException(java.lang.String)
*/
public Exception getException(String msg) throws Exception {
return new StepInterruptedException(msg);
}
/* (non-Javadoc)
* @see org.springframework.batch.io.exception.AbstractExceptionTests#getException(java.lang.String, java.lang.Throwable)
*/
public Exception getException(String msg, Throwable t) throws Exception {
return new RuntimeException(msg, t);
}
}

View File

@@ -0,0 +1,43 @@
/*
* Copyright 2006-2007 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.batch.core.repository;
import org.springframework.batch.core.AbstractExceptionTests;
/**
* @author Dave Syer
*
*/
public class BatchRestartExceptionTests extends AbstractExceptionTests {
/*
* (non-Javadoc)
* @see org.springframework.batch.io.exception.AbstractExceptionTests#getException(java.lang.String)
*/
public Exception getException(String msg) throws Exception {
return new BatchRestartException(msg);
}
/*
* (non-Javadoc)
* @see org.springframework.batch.io.exception.AbstractExceptionTests#getException(java.lang.String,
* java.lang.Throwable)
*/
public Exception getException(String msg, Throwable t) throws Exception {
return new BatchRestartException(msg, t);
}
}

View File

@@ -0,0 +1,30 @@
/*
* Copyright 2006-2007 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.batch.core.repository;
import junit.framework.TestCase;
/**
* @author Dave Syer
*
*/
public class NoSuchBatchDomainObjectExceptionTests extends TestCase {
public void testCreateException() throws Exception {
NoSuchBatchDomainObjectException e = new NoSuchBatchDomainObjectException("Foo");
assertEquals("Foo", e.getMessage());
}
}

View File

@@ -0,0 +1,14 @@
package org.springframework.batch.core.runtime;
import org.springframework.batch.core.domain.JobIdentifier;
import junit.framework.TestCase;
public class SimpleJobIdentifierFactoryTests extends TestCase {
public void testGetJobIdentifier() {
JobIdentifier jobIdentifier = new SimpleJobIdentifierFactory().getJobIdentifier("foo");
assertEquals("foo", jobIdentifier.getName());
}
}

View File

@@ -0,0 +1,59 @@
/*
* Copyright 2006-2007 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.batch.core.runtime;
import junit.framework.TestCase;
/**
* @author Dave Syer
*
*/
public class SimpleJobIdentifierTests extends TestCase {
private SimpleJobIdentifier identifier = new SimpleJobIdentifier("foo");
/**
* Test method for
* {@link org.springframework.batch.core.runtime.SimpleJobIdentifier#SimpleJobIdentifier()}.
*/
public void testSimpleJobIdentifier() {
assertNull(new SimpleJobIdentifier().getName());
}
/**
* Test method for
* {@link org.springframework.batch.core.runtime.SimpleJobIdentifier#getName()}.
*/
public void testGetName() {
assertEquals("foo", identifier.getName());
identifier.setName("bar");
assertEquals("bar", identifier.getName());
}
/**
* Test method for
* {@link org.springframework.batch.core.runtime.SimpleJobIdentifier#toString()}.
*/
public void testToString() {
assertTrue("SimpleJobIdentifier toString should contain name: " + identifier.toString(), identifier.toString()
.indexOf("name=") >= 0);
}
public void testEquals(){
SimpleJobIdentifier testIdentifier = new SimpleJobIdentifier("foo");
assertEquals(testIdentifier,identifier);
}
}

View File

@@ -0,0 +1,172 @@
Product: Clover
License: Open Source License, 0.x, 1.x
Issued: Thu Mar 15 2007 12:55:00 CDT
Expiry: Never
Maintenance Expiry: Never
Key: d24b469cbe33bb71017d39a9d
Name: Andy Colyer
Org: Spring Portfolio
Certificate: AAACUG+Ow8B7/zEbxOMqqKwwrdpP+a1COmJGHco7sCNLjHkHnajPF+dQW
Ct12PMy0uml0s9xuus5wKngJ9OFk5/FZgYzdyIG5/rxEgRevOoLO7uYipoJrkt4TPBwIm4
hxEw+b9xUNP0x1tTqSsgUP6fqSYilMajaHYGuRD9iV3LeP7hwWulpXY3hz3W5WjsKYp3Nf
fPyts/AffWHANGj5DHV+4yGm2IGIzIgHOGx9hISC7boFknmwM/GQ78RO1yzNnkSJ9dHPz2
VdGTrKob36k3OVy7vwwCPpSm+01KDpkY4ZQN4ynqPIFzvJ07F1IBUvU49CGzSvX3v6qmOp
mT11CTGtP49xPafrKNjDDV8PxCsoesEBRaY4FJzquzWz0j6CkIQqidzCj3WDCtog3ct+za
SuuZ51n027sVFhbM69dZZzv8bYCgSHdQ3sG1a9DxM7+6JRfRcIBFgt/V78vK41MF4p9Mi1
qmEPMLizpu7eBo1GDoQ8Lb3EhIWrfxDb4Db3NFc9hYpCKoreFlEw1A+eJlrLeomy43pVtk
SNPTDDoahNrXLeIu7SiRoHiemMrUjWvYtT9jwnVOsIjELa8n8cfW7gMzJdenCcNWl/T3Cr
8rSu3pVfz07AvX6+wQZWqzvGGnlwpnFXu1YJROxITYNINVNKXCAby33Mdbm51DPA3rEyk+
dpS31tU2XrR4iY1Zypja1M0voOkzL74pf9ExgUGeJqyvi5LWTn3b4kGGT/bkwhbbDn6sAA
zlxKRvxsbYOBUzk3UZ448Heg2HwCjwarCh/C0QIcX8vWnUjqssdvxT7Jlr1rZwqK1LKqbH
l7YvP9Ee7SoHfoHrW770yK23u2IdDK44Sf6G3NBE0Muq7W1bcZwrZ1/ZRk8vE2kt0F0fXI
wz7Thjs5lXvcZDJO4nEtXpmSdCaDjUXBpjvsZE2ZjPa2Q1tv3KFhHWqdfNRant7FyeWYg=
=
License Agreement: CLOVER VERSION 1 (ONE) SOFTWARE LICENSE AGREEMENT
1. Licenses and Software
Cenqua Pty Ltd, an Australian Proprietary Limited Company ("CENQUA")
hereby grants to the purchaser (the "LICENSEE") a limited, revocable,
worldwide, non-exclusive, nontransferable, non-sublicensable license
to use the Clover version 1 (one) software (the "Software"),
including any minor upgrades thereof during the Term (hereinafter
defined) up to, but not including the next major version of the
Software. The licensee shall not, or knowingly allow others to,
reverse engineer, decompile, disassemble, modify, adapt, create
derivative works from or otherwise attempt to derive source code from
the Software provided. And, in accordance with the terms and
conditions of this Software License Agreement (the "Agreement"), the
Software shall be used solely by the licensed users in accordance
with the following edition specific conditions:
a) Server Edition
A Server Edition license entitles the Licensee to execute one
instance of Clover Server Edition on one (1) machine for the purposes
of instrumententing source code and generating reports. There are no
limitations on the use of the instrumented source code or generated
reports produced by Server Edition.
b) Workstation Edition
A Workstation Edition license entitles the licensee to use Clover
Workstation Edition on one (1) machine by one (1) individual end
user. Workstation Edition does not permit the generation of reports
for distribution.
c) Team Edition
A Team Edition license entitles the licensee to use Clover Team
edition on any number of machines solely by the licensed number of
users. Reports generated by Clover Team Edition are strictly for use
only by the licensed number of individual end users.
2. License Fee
In exchange for the License(s), the Licensee shall pay to CENQUA a
one-time, up front, non-refundable license fee. At the sole
discretion of CENQUA this fee will be waived for non-commercial
projects. Notwithstanding the Licensee's payment of the License Fee,
CENQUA reserves the right to terminate the License if CENQUA
discovers that the Licensee and/or the Licensee's use of the Software
is in breach of this Agreement.
3. Proprietary Rights
CENQUA will retain all right, title and interest in and to the
Software, all copies thereof, and CENQUA website(s), software, and
other intellectual property, including, but not limited to, ownership
of all copyrights, look and feel, trademark rights, design rights,
trade secret rights and any and all other intellectual property and
other proprietary rights therein. The Licensee will not directly or
indirectly obtain or attempt to obtain at any time, any right, title
or interest by registration or otherwise in or to the trademarks,
service marks, copyrights, trade names, symbols, logos or
designations or other intellectual property rights owned or used by
CENQUA. All technical manuals or other information provided by CENQUA
to the Licensee shall be the sole property of CENQUA.
4. Term and Termination
Subject to the other provisions hereof, this Agreement shall commence
upon the Licensee's opting into this Agreement and continue until the
Licensee discontinues use of the Software or the Agreement terminates
automatically upon the Licensee's breach of any term or condition of
this Agreement (the "Term"). Upon any such termination, the Licensee
will delete the Software immediately.
5. Copying & Transfer
The Licensee may copy the Software for back-up purposes only. The
Licensee may not assign or otherwise transfer the Software to any
third party.
6. Specific Disclaimer of Warranty and Limitation of Liability
THE SOFTWARE IS PROVIDED WITHOUT WARRANTY OF ANY KIND. CENQUA
DISCLAIMS ALL WARRANTIES, EXPRESSED OR IMPLIED, INCLUDING BUT NOT
LIMITED TO THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
PARTICULAR PURPOSE. CENQUA WILL NOT BE LIABLE FOR ANY DAMAGES
ASSOCIATED WITH THE SOFTWARE, INCLUDING, WITHOUT LIMITATION,
ORDINARY, INCIDENTAL, INDIRECT, OR CONSEQUENTIAL DAMAGES OF ANY KIND,
INCLUDING BUT NOT LIMITED TO DAMAGES RELATING TO LOST DATA OR LOST
PROFITS, EVEN IF CENQUA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
DAMAGES.
7. Warranties and Representations
Licensee Indemnification. CENQUA agrees to indemnify, defend and hold
the Licensee harmless from and against any and all liabilities,
damages, losses, claims, costs, and expenses (including reasonable
legal fees) arising out of or resulting from the Software or the use
thereof infringing upon, misappropriating or violating any patents,
copyrights, trademarks, or trade secret rights or other proprietary
rights of persons, firms or entities who are not parties to this
Agreement.
CENQUA Indemnification. The Licensee warrants and represents that the
Licensee's actions with regard to the Software will be in compliance
with all applicable laws; and the Licensee agrees to indemnify,
defend, and hold CENQUA harmless from and against any and all
liabilities, damages, losses, claims, costs, and expenses (including
reasonable legal fees) arising out of or resulting from the
Licensee's failure to observe the use restrictions set forth herein.
8. Publicity
The Licensee grants permission for CENQUA to use Licensee's name
solely in customer lists. CENQUA shall not, without prior consent in
writing, use the Licensee's name, or that of its affiliates, in any
form with the specific exception of customer lists. CENQUA agrees to
remove Licensee's name from any and all materials within 7 days if
notified by the Licensee in writing.
9. Governing Law
This Agreement shall be governed by the laws of New South Wales,
Australia.
10.Independent Contractors
The parties are independent contractors with respect to each other,
and nothing in this Agreement shall be construed as creating an
employer-employee relationship, a partnership, agency relationship or
a joint venture between the parties.
11. Assignment
This Agreement is not assignable or transferable by the Licensee.
CENQUA in its sole discretion may transfer a license to a third party
at the written request of the Licensee.
12. Entire Agreement
This Agreement constitutes the entire agreement between the parties
concerning the Licensee's use of the Software. This Agreement
supersedes any prior verbal understanding between the parties and any
Licensee purchase order or other ordering document, regardless of
whether such document is received by CENQUA before or after execution
of this Agreement. This Agreement may be amended only in writing by
CENQUA.

View File

@@ -0,0 +1,13 @@
log4j.rootCategory=INFO, stdout
log4j.appender.stdout=org.apache.log4j.ConsoleAppender
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
log4j.appender.stdout.layout.ConversionPattern=%d %p [%c] - <%m>%n
log4j.category.org.apache.activemq=ERROR
log4j.category.org.springframework.batch=DEBUG
log4j.category.org.springframework.transaction=INFO
log4j.category.org.hibernate.SQL=DEBUG
# for debugging datasource initialization
# log4j.category.test.jdbc=DEBUG