TaskFactory单例模式利用xml
/**
*
* Copyright (c) 1995-2009 Wonders Information Co.,Ltd.
* 1518 Lianhang Rd,Shanghai 201112.P.R.C.
* All Rights Reserved.
*
* This software is the confidential and proprietary information of Wonders Group.
* (Social Security Department). You shall not disclose such
* Confidential Information and shall use it only in accordance with
* the terms of the license agreement you entered into with Wonders Group.
*
* Distributable under GNU LGPL license by gnu.org
*/ package com.yundaex.common.parent.threadpool; import org.springframework.beans.BeansException;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;
import org.springframework.stereotype.Repository; /**
* <p>
* Title: Adage_[子系统统名]_[模块名]
* </p>
* <p>
* Description: 并发任务工厂,用于动态获取并发任务实例
* 注意:主要用于事务包装的并发任务,在用SPRING包装任务的事务时,需要注意,任务bean和任务代理bean必须均为Prototype类型(singleton为false)
* </p>
*
* @author Jessy
* @version $Revision$ 2010-8-4
* @author (lastest modification by $Author$)
* @since 1.0
*/
@Repository("taskFactory")
public final class TaskFactory implements ApplicationContextAware {
private ApplicationContext applicationContext; private static TaskFactory instance; private TaskFactory() { } /**
* <p>
* Discription:获取任务工厂实例
* </p>
*
* @return
*/
public static TaskFactory getInstance() {
if (instance == null) {
instance = new TaskFactory();
}
return instance;
} /**
* <p>
* Discription:创建并发任务
* </p>
*
* @param <T> 泛型
* @param type 任务类型
* @param taskClass 任务CLASS
* @return
*/
public <T extends Task> T createTask(String type, Class<T> taskClass) {
return taskClass.cast(applicationContext.getBean(type));
} /**
* {@inheritDoc}
*
* @see org.springframework.context.ApplicationContextAware#
* setApplicationContext(org.springframework.context.ApplicationContext)
*/
public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
this.applicationContext = applicationContext; }
}
applicationContext-common-threadpool.xml
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN"
"http://www.springframework.org/dtd/spring-beans.dtd">
<beans>
<description></description>
<bean id="simpleThreadPool" class="com.yundaex.common.parent.threadpool.runtime.SimpleThreadPool"
abstract="true">
</bean>
<bean id="dynamicThreadPool" class="com.yundaex.common.parent.threadpool.runtime.DynamicThreadPool"
abstract="true">
<!--<property name="maxSize" value="${your.module.maxSize}"></property>
<property name="minSize" value="${your.module.minSize}"></property>
<property name="checkPeriod" value="${your.module.checkPeriod}"></property>
<property name="sparePeriod" value="${your.module.sparePeriod}"></property>-->
</bean> <bean id="taskFactory" class="com.yundaex.common.parent.threadpool.TaskFactory"
factory-method="getInstance">
</bean>
</beans>
TaskFactory单例模式利用xml的更多相关文章
- C# 解析html —— 将html转为XHTML,然后利用Xml解析
呵呵,由于正则不熟,所以另谋出路——利用XML去解析html. 要想将抓取到的数据(直接抓取到的是byte[]) 转为XML文档(即XMLDocument对象),有两个要点: 一.判断编码(http ...
- 教你如何利用xml格式的sitemap文件做好SEO
教你如何利用xml格式的sitemap文件做好SEO 浏览: | 更新:-- : 一般的网站中都有网站地图文件,它有HTML格式与XML格式,网站地图可以帮助搜索引擎抓取.帮助用户找到自己所需要的内容 ...
- C#配合利用XML文件构建反射表机制
在设计程序时,无论是界面或是后台代码,我们通常都想留给用户一个较为简单的接口.而我在参与封装语音卡开发函数包的时候,发现各种语音卡的底层函数的接口都是各种整形变量标记值,使用起来极为不变.于是就理解了 ...
- ajax技术实现登录判断用户名是否重复以及利用xml实现二级下拉框联动,还有从数据库中获得
今天学了ajax技术,特地在此写下来作为复习. 一.什么是ajax? 客户端(特指PC浏览器)与服务器,可以在[不必刷新整个浏览器]的情况下,与服务器进行异步通讯的技术 即,AJAX是一个[局部刷新 ...
- spring利用xml配置定时任务
在开发中会经常遇到做定时任务的需求,例如日志定时清理与处理,数据信息定时同步等需求. 1.在spring中利用xml配置定时任务,如下 <!-- ftpiptv信息同步接口定时任务配置--> ...
- 利用XML FOR PATH 合并分组信息
-- ================================================ -- Description:合并分组内容 -- Author:夏保华 -- Date:2009 ...
- java分享第十八天-02( java结合testng,利用XML做数据源的数据驱动)
testng的功能很强大,利用@DataProvider可以做数据驱动,数据源文件可以是EXCEL,XML,YAML,甚至可以是TXT文本.在这以XML为例:备注:@DataProvider的返回值类 ...
- java结合testng,利用XML做数据源的数据驱动示例
testng的功能很强大,利用@DataProvider可以做数据驱动,数据源文件可以是EXCEL,XML,YAML,甚至可以是TXT文本.在这以XML为例: 备注:@DataProvider的返回值 ...
- 利用XML序列化和Asp.Net Web缓存实现站点配置文件
我们经常会遇到这样的场景: 今天来了个业务,需要加一个字段,但是考虑的以后可能有变动,需要配成“活”的. 一般最初的做法就是加一个配置到Web.Config文件的AppSettings中去.但是这样有 ...
随机推荐
- Elasticsearch mapping文档相似性算法
Elasticsearch allows you to configure a scoring algorithm or similarity per field. The similarityset ...
- L90
On Motes and Beams 微尘与栋梁 It is curious that our own offenses should seem so much less heinous than t ...
- leetcode 67. Add Binary (高精度加法)
Given two binary strings, return their sum (also a binary string). For example,a = "11"b = ...
- HDU6118:度度熊的交易计划(入门级最小费用可行流)
度度熊参与了喵哈哈村的商业大会,但是这次商业大会遇到了一个难题: 喵哈哈村以及周围的村庄可以看做是一共由n个片区,m条公路组成的地区. 由于生产能力的区别,第i个片区能够花费a[i]元生产1个商品,但 ...
- java反射中Class对象详解和类名.class, class.forName(), getClass()区别
1.获得类型类 可以看到,对象a是A的一个实例,A是某一个类,在if语句中使用a.getClass()返回的结果正是类A的类型类,在Java中表示一个特定类型的类型类可以用“类型.class”的方式获 ...
- 华为USG6500系列
华为USG6500: ssh 登录配置 time-range 相关配置:<USG6000V1>system-view Enter system view, return user view ...
- 【运维程序】简单的命令控制器(支持定时命令执行、重复定时任务命令和进程管理,开发这个小程序主要是为了方便管理服务进程)【个人github项目】
一.前言: command-controller 一个运维程序,简单的命令控制器(支持定时命令执行和重复定时命令,开发这个程序主要是为了方便管理服务进程) 本来是要用python做的,但是之前做ffm ...
- 如何让Surface RT支持网站的flash
Go to the desktop version of IE10, hit the click ALT button on your keyboard, click on and then Comp ...
- git简单获取远程某个分支代码命令
git clone resource.git git branch -a list all the local and remote branches git checkout [remote bra ...
- apache2.2.25+php5.43开启curl失败的解决方案。
首先还是常规步骤: 1.extension_dir = "C:/server/php/ext" 2.extension=php_curl.dll 3.重启apache,发现curl ...