`
huiseyiyu
  • 浏览: 101412 次
  • 性别: Icon_minigender_1
  • 来自: 苏州
社区版块
存档分类
最新评论
收藏列表
标题 标签 来源
判断操作系统 JAVA验证当前操作系统
public class ValidateOs {


	/**
	 * 判断运行环境是否是Windows
	 * 
	 * @return 返回是否是WINDOWS操作系统,如果TRUE则表示是WINDOW,如果为false则是linux
	 * @version 1.0
	 * @author Quinn update 2011-12-8 下午12:01:54
	 */
	public static boolean isWindowsOS() {
		return System.getProperty("os.name").toUpperCase().indexOf("WINDOWS") != -1;
	}

	/**
	 * 判断运行环境是否是Linux
	 * 
	 * @return 返回是否是LINUX操作系统,如果TRUE则表示是LINUX,如果为false则是window
	 * @version 1.0
	 * @author Quinn update 2011-12-8 下午12:01:54
	 */
	public static boolean isLinuxOS() {
		return System.getProperty("os.name").toUpperCase().indexOf("LINUX") != -1;
	}
}
内存释放组件ext-patch.js extjs Ext&OPOA的内存释放改进 (Ext3.0.0)
// ******************************* Bugs fix ***********************************

Ext.override(Ext.chart.Chart, {
	onDestroy: function(){
		this.bindStore(null);
		var tip = this.tipFnName;
		if(!Ext.isEmpty(tip)){
			delete window[tip];
		}
		Ext.chart.Chart.superclass.onDestroy.call(this);
	}
});

Ext.override(Ext.form.TextField,{
	autoSize : function(){
        if(!this.grow || !this.rendered){
            return;
        }
        if(!this.metrics){
            this.metrics = Ext.util.TextMetrics.createInstance(this.el);
        }
        var el = this.el;
        var v = el.dom.value;
        var d = document.createElement('div');
        d.appendChild(document.createTextNode(v));
        v = d.innerHTML;
        Ext.removeNode(d);
		d = null;
        v += ' ';
        var w = Math.min(this.growMax, Math.max(this.metrics.getWidth(v) + /* add extra padding */ 10, this.growMin));
        this.el.setWidth(w);
        this.fireEvent('autosize', this, w);
    }
});

Ext.override(Ext.Component, {
	onRender : function(ct, position){
        if(!this.el && this.autoEl){
            if(Ext.isString(this.autoEl)){
                this.el = document.createElement(this.autoEl);
            }else{
                var div = document.createElement('div');
                Ext.DomHelper.overwrite(div, this.autoEl);
                this.el = div.firstChild;
            }
            if (!this.el.id) {
                this.el.id = this.getId();
            }
        }
        if(this.el){
            this.el = Ext.get(this.el);
            if(this.allowDomMove !== false){
                ct.dom.insertBefore(this.el.dom, position);
                if (div) {
                    Ext.removeNode(div);
                    div = null;
                }
            }
        }
    }
});
// ************************* improve **********************

(function(){
	Ext.util.TextMetrics.Instance = function(bindTo, fixedWidth){
		var ml = new Ext.Element(document.createElement('div'));
		document.body.appendChild(ml.dom);
		ml.position('absolute');
		ml.setLeftTop(-1000, -1000);
		ml.hide();

		if(fixedWidth){
			ml.setWidth(fixedWidth);
		}

		var instance = {
			getSize : function(text){
				ml.update(text);
				var s = ml.getSize();
				ml.update('');
				return s;
			},
			bind : function(el){
				ml.setStyle(
					Ext.fly(el).getStyles('font-size','font-style', 'font-weight', 'font-family','line-height', 'text-transform', 'letter-spacing')
				);
			},
			setFixedWidth : function(width){
				ml.setWidth(width);
			},
			getWidth : function(text){
				ml.dom.style.width = 'auto';
				return this.getSize(text).width;
			},
			getHeight : function(text){
				return this.getSize(text).height;
			},
			// Add by clue
			destroy	:	function(){
				Ext.destroy(ml);
				delete ml;
			}
		};

		instance.bind(bindTo);

		return instance;
	};
})();
// ******************************* Memory Release *****************************

Ext.override(Ext.Component,{ 
	onDestroy	:	function(){ 
		if(this.plugins){
			Ext.destroy(this.plugins);
		}
		Ext.destroy(this.el);
	}
});

Ext.override(Ext.Panel,{
    onDestroy : function(){
		Ext.destroy(
            this.header,
            this.tbar,
            this.bbar,
            this.footer,
            this.body,
            this.bwrap,
			this.dd
        );
		Ext.Panel.superclass.onDestroy.call(this);
    }
});

Ext.override(Ext.dd.DragDrop,{ 
	onDestroy	:	Ext.emptyFn,
	destroy : function(){
		this.onDestroy();
        this.unreg();
    }
});

Ext.override(Ext.dd.DragSource,{ 
	onDestroy	:	function(){
		Ext.destroy(this.proxy);
		Ext.dd.DragSource.superclass.onDestroy.call(this);
	}
});

Ext.override(Ext.grid.GridDragZone,{
	onDestroy	:	function(){
		Ext.destroy(this.ddel);
		Ext.grid.GridDragZone.superclass.onDestroy.call(this);
	}
});

Ext.override(Ext.dd.StatusProxy,{ 
	onDestroy	:	Ext.emptyFn,
	destroy : function(){
		this.onDestroy();
		Ext.destroy(this.anim,this.el,this.ghost);
    }
});

Ext.override(Ext.grid.GridView,{
	destroy : function(){
        if(this.colMenu){
            Ext.menu.MenuMgr.unregister(this.colMenu);
            this.colMenu.destroy();
        }
        if(this.hmenu){
            Ext.menu.MenuMgr.unregister(this.hmenu);
            this.hmenu.destroy();
        }
		this.initData(null, null);
        this.purgeListeners();

        if(this.grid.enableColumnMove){
			delete Ext.dd.DDM.locationCache[this.columnDrag.id];
			Ext.destroy(this.columnDrag,this.columnDrop);
        }

        Ext.fly(this.innerHd).removeAllListeners();
        Ext.removeNode(this.innerHd);

		Ext.destroy(
            this.el,
            this.mainWrap,
            this.mainHd,
            this.scroller,
            this.mainBody,
            this.focusEl,
            this.resizeMarker,
            this.resizeProxy,
            this.activeHdBtn,
            this.dragZone,
            this.splitZone,
            this._flyweight
        );
        Ext.EventManager.removeResizeListener(this.onWindowResize, this);
    }
});

Ext.override(Ext.tree.TreePanel,{ 
	onDestroy : function(){
        if(this.rendered){
            this.body.removeAllListeners();
            Ext.dd.ScrollManager.unregister(this.body);
			Ext.destroy(this.dropZone,this.dragZone,this.innerCt);
        }
        Ext.destroy(this.root);
        Ext.tree.TreePanel.superclass.onDestroy.call(this);
    }
});

Ext.override(Ext.grid.HeaderDropZone,{ 
	onDestroy	:	function(){
		Ext.destroy(this.proxyTop,this.proxyBottom);
		Ext.grid.HeaderDropZone.superclass.onDestroy.call(this);
	}
});

Ext.override(Ext.menu.Menu,{
	onDestroy : function(){
        Ext.destroy(this.el);
        Ext.menu.MenuMgr.unregister(this);
        Ext.EventManager.removeResizeListener(this.hide, this);
        if(this.keyNav) {
            this.keyNav.disable();
        }
        var s = this.scroller;
        if(s){
            Ext.destroy(s.topRepeater, s.bottomRepeater, s.top, s.bottom);
        }
		this.purgeListeners();
		Ext.menu.Menu.superclass.onDestroy.call(this);
    }
});

Ext.override(Ext.TabPanel,{ // Ext.Panel
	onDestroy	:	function(){
		Ext.destroy(
			this.stack,
			this.stripWrap,
			this.stripSpacer,
			this.strip,
			this.edge,
			this.leftRepeater,
			this.rightRepeater
		);
		Ext.TabPanel.superclass.onDestroy.call(this);
	}
});

Ext.override(Ext.layout.ColumnLayout,{ 
	destroy	:	function(){
		Ext.destroy(this.innerCt);
	}
});

Ext.override(Ext.form.Field,{ 
	onDestroy	:	function(){
		Ext.destroy(this.errorEl,this.errorIcon);
		Ext.form.Field.superclass.onDestroy.call(this);
	}
});

Ext.override(Ext.form.TextField,{
	onDestroy	:	function(){
		Ext.destroy(this.metrics);
		if(this.validationTask){
			this.validationTask.cancel();
			this.validationTask = null;
		}
		Ext.form.TextField.superclass.onDestroy.call(this);
	}
});
自己转存
@Component:泛指应用中所有组件。在applicationContext.xml配置正确的前提下,被其注
解的类会在Spring启动时自动加载到内存。 
@Service:同样标识被注解的类为一个组件,但该类是单例的。 
@Scope:标识被注解的类的作用域。区域范围包括:Singleton、prototype、session、req
uest、globe session 
@AutoWired、@Resource:标识一个被依赖类在主类被初始化的时候会被自动注入。@AutoWi
re默认按照类型装配,并要求依赖对象必须存在;@Resource默认按照名称装配,当找不到?
破ヅ涞腷ean才会按照类型匹配 
@Path、@Produces、@Get、@Post、@Put、@Delete、@FormParam:由于使用restEasy引入。
@Path标识某个类或方法的资源路径,供前台调用使用;@Produces定义了方法返回值类型; 
@Get、@Post、@Put、@Delete是http四种状态,标识方法的状态,同Path结合供前台唯一调
用;标识参数通过form表单传出 @NotBlank、@Size、@NotNull: 
@Select、@Insert、@Update、@Delete、@SelectProvider:


rest注解

@Path、@Path标识某个类或方法的资源路径,供前台调用使用;
@Produces、@Produces定义了方法返回值类型;
@Get、@Get、@Post、@Put、@Delete是http四种状态,标识方法的状态,同Path结合供前台唯一调用;
@Post、
@Put、
@Delete、
@FormParam:标识参数通过form表单传出
 
@Produces(MediaType.TEXT_PLAIN)标记莫个方法,jax-rs则会将该java类型
转换成"text/plain" MIME类型,代表普通文本,同时通过Http响应将该类型的内容发送给客户端

@Path:为资源指定一个相对路径,可标识资源并辅助处理Http请求

GET:@GET所注解的方法用于处理http get请求,当客户端向某个代表每个web资源的url直接发送http get
请求时,jax-rs运行时会调用被@GET所注解的方法来处理get请求

POST:@POST所注解的方法用于处理http post请求

Produces:用于标识MIME媒体类型,这样资源中的方法就会生成该类型的内容并返回给客户端

Consumes:@Consumes注解用于标识MIME媒体类型,这表示了资源中的方法可以接受客户端所请求的类型。
与@Produces注解一样,如果在类上指定了@Consumes注解,该注解就会应用到类中的所有方法;
如果在某个方法上指定了@Consumes注解,那么它会覆盖类上所指定的@Consumes注解。

JAX-
RS还提供了其他一些方便的特性,比如基于参数的注解可以获得请求中的信息,
@QueryParam,就是这样一种注解,它可以从请求URL的查询字符串中获得查询参数。
其他基于参数的注解@MatrixParam,它可以从URL路径的segment部分获取信息;
@HeaderParam可以从HTTP头中获取信息
CookieParam则可以从cookie相关的HTTP头中获得cookie信息。

========================================================================================================

Hibernate Validator 4:
hibernate-validator-4.1.0.Final.jar。
spring配置文件中配置<bean id=“validator” class=“org.springframework.validation.beanvalidation.LocalValidatorFactoryBean” />,
在代码中使用注解的方式标识对与字段的约束


 ◆Min:被@Min所注解的元素必须是个数字,其值要大于或等于给定的最小值。
 ◆Max:被@Max所注解的元素必须是个数字,其值要小于或等于给定的最大值。
 ◆Size:@Size表示被注解的元素必须位于给定的最小值和最大值之间。支持Size验证的数据类型有String、Collection(计算集合的大小)、Map以及数组。
 ◆NotNull:@NotNull确保被注解的元素不能为null。
 ◆Null:@Null确保被注解的元素一定为null。
 ◆Pattern:@Pattern确保被注解的元素(String)一定会匹配给定的Java正则表达式。
 
 
========================================================================================================
 MYBatis:
 
 <!-- 设置SqlSessionFactory -->
<bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean">
<property name="dataSource" ref="dataSource" />
<property name="configLocation" value="classpath:database/beanconfig.xml" />
</bean>
<!-- scan for mappers and let them be autowired -->
<bean class="org.mybatis.spring.mapper.MapperScannerConfigurer">
<property name="basePackage" value="com.huawei.ecc.repository.db" />
</bean>

系统每个模块的持久化操作类都是一个接口。接口中每个API都通过注解的方式绑定了一条sql语句和入参。Eg:
@Select("SELECT codevalue, codename FROM T_SYS_CODE WHERE codeType = #{codeType}")
 List<CodeInfoBean> getCodeInfoByType(@Param("codeType")String codeType);
@SelectProvider(method = "selectContactEmgByConditionSql", type = ContactEmgSql.class)
 List<ContactBean> selectContactByCondition(ContactBean contactBean);
 
 
 
 ========================================================================================================
 Jboss  Cache:
 
 Jboss Cache包括core edition、pojo edition、searchable edition
 Pojo Jboss Cache 是对 core jboss cache API的扩展
 暴露的API非常简单,提供了四个方法:Attach、 dettach 、 getObject 、 getAllObject 
Global site tag (gtag.js) - Google Analytics