我的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(20601)
  • 2. 取模不是取余(2871)
  • 3. spring 事务的 自动装配(1417)
  • 4. 大数阶乘算法~~~(795)
  • 5. quickSort算法~~(625)

评论排行榜

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

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

2007年5月8日

计划~~
写写 辞职后,去用友等大型公司熟悉流程 2年~3年 英语学扎实,然后争取去外企 2-3年,如果学不到东西 1年 出来后去小公司混~~~
posted @ 2007-05-31 23:25 刘甘泉 阅读(289) | 评论 (1) | 编辑 收藏
 
取模不是取余
很多次都被欺骗了,取余不是取模 mod!=%
取模的公式 a mod n=a-floor(a/n)n;
floor是地板
用负数试试就知道了~~~
posted @ 2007-05-25 17:51 刘甘泉 阅读(2871) | 评论 (0) | 编辑 收藏
 
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 刘甘泉 阅读(1417) | 评论 (4) | 编辑 收藏
 
泛型的获取class
泛型中获取class比较麻烦,找到的牛人江南白衣的方法 Class entityClass = (Class) ((ParameterizedType) getClass().getGenericSuperclass()).getActualTypeArguments()[0];
posted @ 2007-05-12 18:23 刘甘泉 阅读(330) | 评论 (0) | 编辑 收藏
 
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 刘甘泉 阅读(318) | 评论 (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 刘甘泉 阅读(625) | 评论 (0) | 编辑 收藏