1、线程
2、jaxb
3、加载配置文件
4、xjc工具
xjc.sh -p com.test.type reports.xsd -d work
选项说明:
-p:指定生成的类的包名
-d:指定存放类的目标目录
5、spring定时器:定时执行excute方法
protected void process()
{
ExecutorService executorService;
//开10个线程
executorService = Executors.newFixedThreadPool(10);
//来一批数据,提交一个线程
executorService.submit(new Runnable()
{
@Override
public void run()
{
//do something
}
});
}
2、jaxb
public void init() throws Exception
{
InputStream input = this.getClass()
.getClassLoader()
.getResourceAsStream("conf/report.xml");
JAXBContext jc = JAXBContext.newInstance("com.dxy.report.types");
Unmarshaller u = jc.createUnmarshaller();
Reports reports = (Reports) u.unmarshal(input);
List<ReportType> reportList = reports.getReport();
for (ReportType reportType : reportList)
{
reportDefinitions.add(new ReportDefinitionImpl(reportType));
}
}
3、加载配置文件
public static void doTest()
{
ApplicationContext appContext = new ClassPathXmlApplicationContext(
"META-INF/spring/service-context.xml");
A a= (A) appContext.getBean("id");
}
4、xjc工具
xjc.sh -p com.test.type reports.xsd -d work
选项说明:
-p:指定生成的类的包名
-d:指定存放类的目标目录
5、spring定时器:定时执行excute方法
<bean id="report_clearHistory" class="org.springframework.scheduling.quartz.CronTriggerBean">
<property name="jobDetail">
<bean
class="org.springframework.scheduling.quartz.MethodInvokingJobDetailFactoryBean">
<property name="targetObject">
<bean
class="com.dxy.ftp.CleanHistoryReportFileTimerTask">
<property name="fileAndFtpService" ref="report_FileAndFtpService"></property>
</bean>
</property>
<property name="targetMethod">
<value>execute</value>
</property>
<property name="concurrent" value="false" />
</bean>
</property>
<property name="cronExpression">
<value>${report.localfile.clean.triggerCron}</value>
</property>
</bean>
<bean id="report_schedulerFactory"
class="org.springframework.scheduling.quartz.SchedulerFactoryBean"
destroy-method="destroy">
<property name="triggers">
<list>
<ref bean="report_clearHistory" />
</list>
</property>
</bean>
<bean id="holder"
class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
<property name="systemPropertiesModeName" value="SYSTEM_PROPERTIES_MODE_OVERRIDE" />
<property name="ignoreResourceNotFound" value="true" />
<property name="locations">
<list>
<value>classpath*:conf/timertask.properties</value>
</list>
</property>
</bean>
public void execute()
{
holdingDays = 3;
for (SourceType sourceType : SourceType.values())
{
try
{
fileAndFtpService.clearLocalReportFile(sourceType, holdingDays);
}
catch (ReportException e)
{
//
}
}
}