java笔记

阅读更多
1、线程
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 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方法

		
			
				
					
						
					
				
				
					execute
				
				
			
		
		
			${report.localfile.clean.triggerCron}
		
	

	
		
			
				
				
			
		
	

	
		
		
		
			
				classpath*:conf/timertask.properties
			
		
	

public void execute()
    {
        holdingDays = 3;
        
        for (SourceType sourceType : SourceType.values())
        {
            try
            {
                fileAndFtpService.clearLocalReportFile(sourceType, holdingDays);
            }
            catch (ReportException e)
            {
                //
            }
        }
    }

你可能感兴趣的:(java笔记)