随笔-6  评论-3  文章-0  trackbacks-0
  2006年10月31日

本人学习JAVA差不多3年了吧,回想过去的3年,突然发现自己在技术上没有特别自豪的东西,JAVA编程思想也改了好几编,说不上精通但也很熟悉,各个流行框架差不多都用过,说不上精通但也可以熟练用.
性能优化上,也就建索引,用缓存,页面做静态化,分库,读写分离.最近学习了一下python,语言特性不是很了解,但也能写出小功能块.

JAVA牛人,告诉我,怎么才能让自己强大起来,回首3年没有自豪的技术,极度郁闷中

不在沉默中爆发,就在沉默中死亡!!!!!1

posted @ 2007-09-30 11:25 野风 阅读(166) | 评论 (0)编辑 收藏
系统架构: webwork+spring+hibernate
 
为了减少数据库处理压力,准备对操作进行读写分离,但分析了一下,还是准备不做了

Hibernate中起用了延迟加载,所以在web.xml 配置了OpenSessionInviewFiter ,一次 Session操作时不会马上关闭,但是同一个session中不能出现两个数据源,读写分离失败.
虽然在spring 配置多例,能处理这个问题,但这样也带来了数据库连接的增多,

现在还想不好怎么来解决这个问题,不知道那位大虾能帮助一下,谢谢!!!!!!!!!!
posted @ 2006-11-21 14:23 野风 阅读(1053) | 评论 (1)编辑 收藏
关于IBatis缓存使用的一个BUG

关于IBatis.Net 版本1.321里面的cacheModel有一个BUG,好大的。当你使用CacheModel

而同时查询出来的结果是NULL的话,IBatis缓存就会有问题。在IBatis.Net 版本1.32里面一共有3处。

MappedStatements 400行处, 527 行 778行

应该改为

 

obj = RunQueryForObject(request, session, parameterObject, resultObject);

                                   if(obj!=null)

                                   {

                                          _statement.CacheModel[key] = obj;

                                   }

每一个缓存前,判断是否为空。

posted @ 2006-11-17 11:37 野风 阅读(943) | 评论 (0)编辑 收藏
public class TestString {
    public TestString() {
    }

    public static void main(String[] args) {
        String s=new String("Hello");
        modify(s);
        System.out.println("s===="+s);
    }

    public static void modify(String s)
    {
        s+="world";
      }
}

为什么是输出Hello,而不是Helloworld? 

java里面会对 String ,int ,Integer 等基本类型,会用值进行传递,在modify 时会clone拷贝一副本在内存里面,但是打印出来的时候,还是按原来内容
其他Object类型,按照内存地址进行传递的,所以在modify 的时候会把值改掉,打印出来也会是“Hello world”
posted @ 2006-10-31 16:46 野风 阅读(273) | 评论 (0)编辑 收藏

package com.xiewei.soft.text;

import java.util.TimerTask;

public class HelloWorldTask extends TimerTask{
  public  void  run (){
   System.out.print("Hello world");
  }
}



package com.xiewei.soft.text;

import java.io.IOException;

import org.springframework.context.ApplicationContext;
import org.springframework.context.support.FileSystemXmlApplicationContext;

public class Fixed {
  public static void main(String[] arg) throws IOException{

   ApplicationContext ctx=new FileSystemXmlApplicationContext("JavaSource/conf/timetask.xml");
   System.in.read();
  }
}

然后在spring配置文件中插入
<beans>
  <bean id ="helloWordTask"  class="com.xiewei.soft.text.HelloWorldTask" />
  <bean id="timerTask" class="org.springframework.scheduling.timer.ScheduledTimerTask">
    <property name="delay">
      <value>1000</value>
    </property>
    <property name="period">
      <value>3000</value>
    </property>
    <property name="timerTask">
      <ref local="helloWordTask"/>
    </property>
  </bean>
  <bean id="timerFactory" class="org.springframework.scheduling.timer.TimerFactoryBean">
   <property name="scheduledTimerTasks">
      <list>
      <ref local="timerTask"/>
      </list>
    </property>
  </bean>
</beans>

测试成功!!!!!!!

posted @ 2006-10-31 15:18 野风 阅读(1495) | 评论 (1)编辑 收藏

/**
   *
   * 解析文件,取出URL地址
   *
   */
 public static void regexStr(){
  String input="飞机但是http://mail.Sohu.com.cn飞机恺撒";
  Pattern p = Pattern.compile("http://[*[a-zA-Z]|w{3}].*[a-zA-Z]");
  Matcher m = p.matcher(input);
  m.find();
  String str=m.group();
        System.out.print(str);
  
  
 }
/**
 * 根据URL,把网页保存到本地
 * @param urlStr
 * @param filename
 * @return
 */ 
 public  static  boolean  getUrlToFileInputStream(String urlStr, String filename){
   
   DataInputStream dataInputStream=null;
   try{
      URL url = new URL(urlStr);
           URLConnection conn = url.openConnection();
           dataInputStream = new DataInputStream(conn.getInputStream());
          
     }catch(Exception e){
      e.getMessage();
   
     }
     DataOutputStream dataoutputstream = null;
   if(dataInputStream !=null){
         try {
    dataoutputstream = new DataOutputStream(new BufferedOutputStream(new FileOutputStream(filename)));
   
   byte b[] = new byte[1024*10];
   int len = 0;
   while ((len = dataInputStream.read(b, 0, 1024)) != -1) {
    dataoutputstream.write(b, 0, len);
   }

   dataoutputstream.flush();
         } catch (Exception e) {
    // TODO Auto-generated catch block
    e.printStackTrace();
   }
            return true;
   }else{
    return false;
   }
    
    
  }

posted @ 2006-10-31 15:06 野风 阅读(1255) | 评论 (1)编辑 收藏