| Deutsch English Français Italiano |
|
<67e69b4c$0$711$14726298@news.sunsite.dk> View for Bookmarking (what is this?) Look up another Usenet article |
Path: ...!2.eu.feeder.erje.net!feeder.erje.net!news.swapon.de!fu-berlin.de!dotsrc.org!filter.dotsrc.org!news.dotsrc.org!not-for-mail
Date: Fri, 28 Mar 2025 08:51:24 -0400
MIME-Version: 1.0
User-Agent: Mozilla Thunderbird
Subject: Re: Spring Batch
Newsgroups: comp.os.vms
References: <vrcisq$2rvno$1@dont-email.me>
Content-Language: en-US
From: =?UTF-8?Q?Arne_Vajh=C3=B8j?= <arne@vajhoej.dk>
In-Reply-To: <vrcisq$2rvno$1@dont-email.me>
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
Lines: 126
Message-ID: <67e69b4c$0$711$14726298@news.sunsite.dk>
Organization: SunSITE.dk - Supporting Open source
NNTP-Posting-Host: f0f7bf5d.news.sunsite.dk
X-Trace: 1743166285 news.sunsite.dk 711 arne@vajhoej.dk/68.14.27.188:57504
X-Complaints-To: staff@sunsite.dk
Bytes: 4785
On 3/18/2025 3:51 PM, Arne Vajhøj wrote:
> I am happy to report that Spring Batch 4.3 works fine on
> VMS x86-64 (and probably also on VMS Itanium, but not on
> VMS Alpha due to too old Java version).
>
> For database, XML, JSON and CSV the following jar files:
> The code and configuration is the same as on any other platform.
Spring Batch can read/write from/to relational databases and a few NoSQL
databases
as well: MongoDB, Neo4J and Redis.
Obviously it does not read/write VMS index-sequential files out of the box.
But since I happen to have a library allowing JVM languages to access VMS
index-sequential files, then creating a wrapper allowing Sping Batch to
access
them was tempting.
So I did.
First the simple model with only one index-sequential file.
import org.springframework.batch.item.ExecutionContext;
import org.springframework.batch.item.NonTransientResourceException;
import org.springframework.batch.item.ParseException;
import org.springframework.batch.item.UnexpectedInputException;
import org.springframework.batch.item.support.AbstractItemStreamItemReader;
import dk.vajhoej.isam.IsamException;
import dk.vajhoej.isam.IsamResult;
import dk.vajhoej.isam.IsamSource;
import dk.vajhoej.record.RecordException;
public class SingleIsamItemReader<T> extends
AbstractItemStreamItemReader<T> {
private IsamSource source;
private Class<T> type;
private IsamResult<T> result;
public IsamSource getSource() {
return source;
}
public void setSource(IsamSource source) {
this.source = source;
}
public Class<T> getType() {
return type;
}
public void setType(Class<T> type) {
this.type = type;
}
@Override
public void open(ExecutionContext ec) {
try {
result = source.readStart(type);
} catch (IsamException e) {
throw new RuntimeException(e);
} catch (RecordException e) {
throw new RuntimeException(e);
}
}
@Override
public T read() throws Exception, UnexpectedInputException,
ParseException, NonTransientResourceException {
if(result.read()) {
return result.current();
} else {
return null;
}
}
@Override
public void close() {
try {
result.close();
source.close();
} catch (IsamException e) {
throw new RuntimeException(e);
}
}
}
<bean id="foobarSource" class="dk.vajhoej.isam.local.LocalIsamSource">
<constructor-arg value="foobar.isq"/>
<constructor-arg value="dk.vajhoej.vms.rms.IndexSequential"/>
<constructor-arg value="true"/>
</bean>
<bean id="foobarReader" class="SingleIsamItemReader">
<property name="source" ref="foobarSource" />
<property name="type" value="somepackage.Foobar"/>
</bean>
import java.util.List;
import org.springframework.batch.item.support.AbstractItemStreamItemWriter;
import dk.vajhoej.isam.IsamSource;
public class SingleIsamItemWriter<T> extends
AbstractItemStreamItemWriter<T> {
private IsamSource source;
public IsamSource getSource() {
return source;
}
public void setSource(IsamSource source) {
this.source = source;
}
@Override
public void write(List<? extends T> items) throws Exception {
for(T item : items) {
source.create(item);
}
}
}
<bean id="foobarSource" class="dk.vajhoej.isam.local.LocalIsamSource">
<constructor-arg value="foobar.isq"/>
<constructor-arg value="dk.vajhoej.vms.rms.IndexSequential"/>
<constructor-arg value="false"/>
</bean>
<bean id="foobarReader" class="SingleIsamItemWriter">
<property name="source" ref="foobarSource" />
</bean>
Arne