The below query will describe the table.
select
distinct(name), coltype, length from sysibm.syscolumns where tbname =
'<table_name>' for read only with ur
|
select
distinct(name), coltype, length from sysibm.syscolumns where tbname =
'<table_name>' for read only with ur
|
package com.thirdpartyapi;
import java.util.Calendar;
public class WishCustomer {
public void sayWishes() {
Calendar cal = Calendar.getInstance();
int currHour = cal.get(Calendar.HOUR_OF_DAY);
if(currHour < 12) {
System.out.println("Dear Valued Customer, Good Morning.....");
} else if(currHour >= 12 && currHour < 18) {
System.out.println("Dear Valued Customer, Good Afternoon.....");
} else if(currHour >= 18 && currHour < 24) {
System.out.println("Dear Valued Customer, Good Evening.....");
}
}
}
|
<bean id=”wishCustomer” class="com.thirdpartyapi.WishCustomer"
/>
|
package com.saywish;
import java.lang.reflect.Method;
import java.util.Calendar;
import java.util.TimeZone;
import
org.springframework.beans.factory.support.MethodReplacer;
public class WishCustomerReplacer implements MethodReplacer {
public Object reimplement(Object arg0, Method arg1, Object[]
arg2) throws Throwable {
Calendar cal = Calendar.getInstance();
cal.setTimeZone(TimeZone.getTimeZone("IST"));
//IST is hard coded,
can be pass dynamically based on user location
int currHour = cal.get(Calendar.HOUR_OF_DAY);
if(currHour < 12) {
System.out.println("Dear Valued Customer, Good Morning.....");
} else if(currHour >= 12 && currHour < 18) {
System.out.println("Dear Valued Customer, Good Afternoon.....");
} else if(currHour >= 18 && currHour < 24) {
System.out.println("Dear Valued Customer, Good Evening.....");
}
return null;
}
}
|
<bean id="wishCustomer" class="com.thirdpartyapi.WishCustomer" >
<replaced-method name="sayWishes"
replacer="wishCustomerReplacer" />
</bean>
<bean id="wishCustomerReplacer" calss="com.saywish.WishCustomerReplacer"
/>
|
package
com.scb.spring;
public class
ConstructorInjection {
private int bankid;
private
String name;
private double salary;
private
SupportingInfo supportingInfo;
public
ConstructorInjection(int
bankid, String name, double
salary, SupportingInfo
supportingInfo) {
this.bankid =
bankid;
this.name =
name;
this.salary =
salary;
this.supportingInfo = supportingInfo;
}
public
String getEmpInfo() {
return "Bank
ID :"+ getBankid() +", Name :"+ name +",
Salary :"+salary ;
}
public int
getBankid() {
return bankid;
}
public
String getName() {
return name;
}
public double
getSalary() {
return salary;
}
public
SupportingInfo getSupportingInfo() {
return supportingInfo;
}
}
|
<beans>
<bean id="constructorInjection" class="com.scb.spring.ConstructorInjection">
<constructor-arg index="0"type=”int” value="1361606" /> <constructor-arg index="1" type=”java.lang.String” value="Paramesh" />
<constructor-arg index="2"
type=”double” value="1234" />
<constructor-arg index="3" ref=”supportingInfo”
/>
</bean>
<bean id=”supportingInfo”
class=”com.scb.spring.SupportingInfo” />
</beans> |
package
com.scb.spring;
public class
ConstructorInjection {
private int bankid;
private
String name;
private double salary;
private
SupportingInfo supportingInfo;
public
String getEmpInfo() {
return "Bank
ID :"+ getBankid() +", Name :"+ name +",
Salary :"+salary ;
}
public void
setBankid(int bankid) {
this.bankid =
bankid;
}
public int
getBankid() {
return bankid;
}
public void
setName(String name) {
this.name =
name;
}
public
String getName() {
return name;
}
public void
setSalary(double salary) {
this.salary =
salary;
}
public double
getSalary() {
return salary;
}
public
SupportingInfo getSupportingInfo() {
return supportingInfo;
}
public void
setSupportingInfo(SupportingInfo supportingInfo) {
this.supportingInfo =
supportingInfo;
}
}
|
<bean id="
constructorInjection" class="com.scb.spring.ConstructorInjection">
<property name="bankid" value="1361606" /> <property name="name" value="Paramesh" />
<property name="salary" value="1234" />
<property name="supportingInfo" ref="supportingInfo" />
</bean>
<bean id=”supportingInfo”
class=”com.scb.spring.SupportingInfo” />
</beans> |
Data Type
|
Element
|
Description
|
java.util.List/
array
|
<list>
|
Helps to inject a
list of values, allowing duplicates.
|
java.util.Set
|
<set>
|
Helps to inject a
set of values, without duplicates.
|
java.util.Map
|
<map>
|
Helps to inject a
collection of name-value pairs where name and value can be of any type.
|
java.util.Properties
|
<props>
|
Helps to inject a
collection of name-value pairs where the name and value are both Strings.
|
Another Bean /
Any java class
|
<ref>
|
Helps to inject
another bean.
|
<bean
id="defaultTokenizer"
class="org.springframework.batch.item.file.transform.DelimitedLineTokenizer">
<property
name="delimiter" value="," />
</bean>
<bean
id="fieldSetMapper"
class="com.mapper.CustomDataUploadFieldSetMapper" />
<bean
id="defaultLineMapper"
class="org.springframework.batch.item.file.mapping.DefaultLineMapper">
<property
name="lineTokenizer"
ref="defaultTokenizer"></property>
<property
name="fieldSetMapper"
ref="fieldSetMapper"></property>
</bean>
<bean
id="customDataItemReader"
class="com.reader.CustomDataLoadReader"
scope="prototype">
<property
name="lineMapper"
ref="defaultLineMapper"></property>
</bean>
|
<bean
id="customDataItemReader"
class="com.reader.customerDataItemReader"
scope="prototype">
<property name="lineMapper">
<bean
class="com.mapper.CustomLineMapper">
<property
name="lineTokenizer">
<bean
class="org.springframework.batch.item.file.transform.DelimitedLineTokenizer">
<property
name="delimiter" value="," />
</bean>
</property>
<property
name="fieldSetMapper">
<bean
class="com.mapper.SegmentFieldSetMapper" />
</property>
</bean>
</property>
</bean>
|
public class CustomLineMapper<T> extends DefaultLineMapper<T>
{
private LineTokenizer lineTokenizer;
private FieldSetMapper<CustomerInformationVO>
fieldSetMapper;
public <T> mapLine(String line, int
lineNumber) throws Exception {
try {
setLineTokenizer(new DelimitedLineTokenizer(StringUtils.contains(
line, '|') ? '|' : ','));
return this.fieldSetMapper.mapFieldSet(this.lineTokenizer
.tokenize(line));
} catch (Exception ex) {
throw new FlatFileParseException("Parsing error at line: "
+
lineNumber + ", input=[" + line + "]", ex, line,
lineNumber);
}
}
public LineTokenizer getLineTokenizer() {
return lineTokenizer;
}
public void setLineTokenizer(LineTokenizer lineTokenizer) {
this.lineTokenizer = lineTokenizer;
}
public void afterPropertiesSet() {
Assert.notNull(this.lineTokenizer, "The
LineTokenizer must be set");
Assert.notNull(this.fieldSetMapper, "The
FieldSetMapper must be set");
}
public FieldSetMapper<CustomerInformationVO>
getFieldSetMapper() {
return fieldSetMapper;
}
public void setFieldSetMapper(
FieldSetMapper<CustomerInformationVO>
fieldSetMapper) {
this.fieldSetMapper = fieldSetMapper;
}
}
|