我的java发迹史

 
 

常用链接

  • 我的随笔
  • 我的评论
  • 我的参与
  • 最新评论

留言簿(3)

  • 给我留言
  • 查看公开留言
  • 查看私人留言

随笔档案

  • 2007年5月 (8)
  • 2007年4月 (2)

搜索

  •  

最新评论

  • 1. re: Java中的transient[未登录]
  • 看来我对持久化和序列化的了解连皮毛都算不上阿,这个例子简单明了,很好,不过这个blog对code的支持不够友好阿,多谢博主
  • --Merlin
  • 2. re: Java中的transient
  • 一看例子就明白了,写的挺好的。
  • --風嗜塵
  • 3. re: Java中的transient[未登录]
  • @cheng
    很好很强大
  • --test
  • 4. re: Java中的transient
  • 例子挺好,明白了,谢啦@cheng
  • --了了
  • 5. re: Java中的transient
  • 写的很好。切中要点
  • --了凡

阅读排行榜

  • 1. Java中的transient(20594)
  • 2. 取模不是取余(2867)
  • 3. spring 事务的 自动装配(1414)
  • 4. 大数阶乘算法~~~(791)
  • 5. quickSort算法~~(621)

评论排行榜

  • 1. Java中的transient(6)
  • 2. spring 事务的 自动装配(4)
  • 3. 计划~~(1)
  • 4. 取模不是取余(0)
  • 5. 泛型的获取class(0)

Powered by: 博客园
模板提供:沪江博客
BlogJava | 首页 | 发新随笔 | 发新文章 | 联系 | 聚合 | 管理

2007年5月31日

计划~~
写写 辞职后,去用友等大型公司熟悉流程 2年~3年 英语学扎实,然后争取去外企 2-3年,如果学不到东西 1年 出来后去小公司混~~~
posted @ 2007-05-31 23:25 刘甘泉 阅读(285) | 评论 (1) | 编辑 收藏
 

2007年5月25日

取模不是取余
很多次都被欺骗了,取余不是取模 mod!=%
取模的公式 a mod n=a-floor(a/n)n;
floor是地板
用负数试试就知道了~~~
posted @ 2007-05-25 17:51 刘甘泉 阅读(2867) | 评论 (0) | 编辑 收藏
 

2007年5月13日

spring 事务的 自动装配

今天在做东西的时候遇到了个问题,我写的代码一般是一个manager对应一个dao,如果在spring 中应用事务的时候 ,
一般人都用的是声明式事务的方式,也就是用的是TransactionProxyFactoryBean这个,但是用这个后它只能针对一个target来进行 事务管理,
所以我用了自动代理方式进行事务的bean create。假如有多个方法相识的manager时就可以用这个了。

spring配置文件如下
 

<bean id="matchNameInterceptor"
          
class="org.springframework.transaction.interceptor.NameMatchTransactionAttributeSource">  //通过名称来进行匹配,以及transactiondefinition 
        <property name="properties">
            
<props>
                
<prop key="get*">PROPAGATION_REQUIRED,readOnly</prop>
                
<prop key="find*">PROPAGATION_REQUIRED,readOnly</prop>
                
<prop key="load*">PROPAGATION_REQUIRED,readOnly</prop>
                
<prop key="insert*">PROPAGATION_REQUIRED</prop>
            
</props>
        
</property>
    
</bean>
    
<bean id="transactionInterceptor"
          
class="org.springframework.transaction.interceptor.TransactionInterceptor">  //事务的 interceptor 
        <property name="transactionManager" ref="transactionManager"/>
        
<property name="transactionAttributeSource" ref="matchNameInterceptor"/>
    
</bean>

    
    
<bean id="autoProxyCreator"
          
class="org.springframework.aop.framework.autoproxy.BeanNameAutoProxyCreator">  //最关键的~~自动对所列表的bean进行装配,
        <property name="interceptorNames">
            
<list>
                
<idref local="transactionInterceptor"/>    //将interceptor 和bean联合起来 所需要装配的interceptor ,也可以是其他的interceptor 
            </list>
        
</property>
        
<property name="beanNames">
            
<list>
                
<idref local="iThreadManager"/>  //这里为需要装配的bean 的list 
                <idref local="iUserManager"/>
            
</list>
        
</property>
    
</bean>



有不对的地方~欢迎各位大大指教

posted @ 2007-05-13 21:04 刘甘泉 阅读(1414) | 评论 (4) | 编辑 收藏
 

2007年5月12日

泛型的获取class
泛型中获取class比较麻烦,找到的牛人江南白衣的方法 Class entityClass = (Class) ((ParameterizedType) getClass().getGenericSuperclass()).getActualTypeArguments()[0];
posted @ 2007-05-12 18:23 刘甘泉 阅读(327) | 评论 (0) | 编辑 收藏
 

2007年5月8日

bubble & selection sort

//bubblesort--------------------------------------------------------------------------
void bubbleSort(int v[],int len){
 for (;len>0;len--)
  for (int i=0;i<len;i++) 
   if(v[i]>v[i+1])swap(v[i],v[i+1]);
}
//bubblesort----------------------------------------------------------------------------

//selection sort---------------------------------------------------------------------
void selectionSort(int v[],int len){
 int k,j,i; 
 for (j=0;k=j,j<=len;j++)
 {
  for (i=j;i<=len;i++) 
   if(v[k]>v[i])k=i;
  if(k!=j) 
  swap(v[k],v[j]); 
 }
}
//selection sort---------------------------------------------------------------------

posted @ 2007-05-08 16:51 刘甘泉 阅读(315) | 评论 (0) | 编辑 收藏
 
quickSort算法~~

#include <iostream.h>
void Swap( int&, int&);
void quickSort(int *R,int low,int high);
int partition(int *R,int i,int j);
void swap(int& x,int& y)
{
 int iTemp=x;
 x=y;
 y=iTemp;
}
int partition(int v[],int i,int j)
{
 int tempSave=v[i];
 while(i<j)
 {
  while(v[j]>=tempSave && i<j)
   j--;
  swap(v[i],v[j]);
  while(v[i]<=tempSave && i<j)
   i++;
  swap(v[i],v[j]);
 }
 return i;
}

void quickSort(int v[],int low ,int high)
{
 int tempPos;
 if (low<high)
 {
  tempPos=partition(v,low,high);
  quickSort(v,low,tempPos-1);
  quickSort(v,tempPos+1,high);
 }

}


void main()
{
int i;
int R[11]={-1,7,12,3,5,8,6,2,9,14,11};
for(i=0;i<=10;i++)
cout << R[i] << endl ;
quickSort(R,1,10);
for(i=0;i<=10;i++)
cout << R[i] << endl ;
}

posted @ 2007-05-08 10:25 刘甘泉 阅读(621) | 评论 (0) | 编辑 收藏
 

2007年5月6日

二叉树的LVR,VLR,LRV遍历的递归和非递归算法~
#include #define maxsize 100 class BitTree { public: int data; BitTree LChild(); BitTree RChild(); int flag; BitTree(){ data=0; flag=0; } BitTree(int d){ data=d; flag=0; }; protected: private: }; BitTree BitTree::LChild(){ BitTree d(1); return d; } BitTree BitTree::RChild(){ BitTree d(1); return d; } struct SqStack { BitTree Elem[maxsize]; int top; SqStack(){ top=0; }; }; class Stack { public: Stack(SqStack sq); virtual ~Stack(); void push(BitTree bit); BitTree pop(); bool isEmpty(); protected: private: SqStack sq; }; Stack::Stack(SqStack sq){ Stack::sq=sq; } void Stack::push(BitTree bit){ sq.Elem[sq.top]=bit; sq.top++; } BitTree Stack::pop(){ BitTree temp; temp=sq.Elem[sq.top]; sq.top--; return temp; } bool Stack::isEmpty(){ return sq.top?true:false; } Stack::~Stack(){ } //中序遍历 非递归 void LVRList(BitTree t){ SqStack *s; s=new SqStack(); Stack stackD(*s); BitTree p=t; while (&p!=NULL ||!stackD.isEmpty()) { while (&p!=NULL) { stackD.push(p); p=p.LChild(); } if (!stackD.isEmpty()) { p=stackD.pop(); cout<
posted @ 2007-05-06 10:35 刘甘泉 阅读(610) | 评论 (0) | 编辑 收藏
 

2007年5月5日

大数阶乘算法~~~
将计算结果的每一位数放在一个数组里面~~ void printme(int id){ int *pts=new int[4*id]; int j,r; //将数组全部置0,数组的首地址放结果的length; //将第一位和第二位置1 for (int i=1;i<(4*id);i++) *(pts+i)=0; *pts=1; *(pts+1)=1; int num=1; //迭代计算xxx! for (i=1;i10) { for (r=1;r9) num++; *(pts+r+1)+=*(pts+r)/10; *(pts+r)=*(pts+r)%10; } } } } for ( i=num;i>0;i--) { cout<<*(pts+i); } delete [] pts; } 在这里记下了~~
posted @ 2007-05-05 20:02 刘甘泉 阅读(791) | 评论 (0) | 编辑 收藏
 

2007年4月22日

位运算
一共3个移位运算符,左移位<<,右移位>>和无符号移位>>>。左移位<<在低位处补0。右移位>>若值为正则在高位插入0,若值为负则在高位插入1。无符号右移位>>>无论正负都在高位处插入0。 非运算符~ &对两个整型操作数中对应位执行布尔代数,两个位都为1时输出1,否则0。 ^对两个整型操作数中对应位执行布尔代数,两个位相等0,不等1。 |对两个整型操作数中对应位执行布尔代数,两个位都为0时输出0,否则1。
posted @ 2007-04-22 17:40 刘甘泉 阅读(253) | 评论 (0) | 编辑 收藏
 
Java中的transient
Java中的transient,看jdk源码的时候突然忘了这个是什么了,查了一下,是用于声明序列化的时候不被存储的,在这里记下
posted @ 2007-04-22 12:35 刘甘泉 阅读(20594) | 评论 (6) | 编辑 收藏
 
仅列出标题