躺在沙滩上的小猪

快乐的每一天

#

Hibernate Annotations(1)

     摘要: 今天有时间大体看了一下Hibernate Annotations,决定放弃xdoclet生成hbm的想法,开始学习annotation.首先大体的来看一下:一:Class Level:1:通过@Entity声明当前pojo为实体Bean2:通过@Table定义对应数据库表的属性   name:表名,默认实体类名   uniqueConstraints:定义表...  阅读全文

posted @ 2006-03-09 22:50 martin xus| 编辑 收藏

应需求添加每天定时生成索引

无非就是两种方法
1:Servlet
2: Listener
 
Servlet:
package 

import org.apache.log4j.Logger;
import javax.servlet.http.HttpServlet;
import java.util.Calendar;
import java.util.Date;
import java.util.Timer;
import java.util.TimerTask;

/**
 * 
@author martin
 
*/
public class LuceneTimerServlet extends HttpServlet {
    
private static Logger logger = Logger.getLogger(LuceneTimerServlet.class);
    
private static Timer timer;

    
static {
        timer 
= new Timer(true);
        timer.schedule(
new TimerTask() {
            
public void run() {
                System.out.println(
"开始创建索引@" + getTime(Calendar.getInstance()));
                TaxDocIndexer indexer 
= new TaxDocIndexer();
                indexer.setFirstRun(Boolean.TRUE);
                indexer.fetch();
                System.out.println(
"索引创建成功@" + getTime(Calendar.getInstance()));
            }
        },
                getFirstTime(),
                getPeriod()
        );
    }


    
public void destroy() {
        logger.debug(
"LuceneTimerServlet.destroy() begin");
        timer.cancel();
    }

    
/**
     * 从服务启动起算,第二天零时开始执行
     *
     * 
@return Timer第一次执行时间
     
*/
    
private static Date getFirstTime() {
        Calendar calendar 
= Calendar.getInstance();
        calendar.add(Calendar.DAY_OF_YEAR, 
1);
        calendar.set(Calendar.HOUR_OF_DAY, 
0);
        calendar.set(Calendar.MINUTE, 
0);
        calendar.set(Calendar.SECOND, 
0);
        logger.debug(
"开始执行时间:" + getTime(calendar));
        
return calendar.getTime();
    }

    
/**
     * 
@param calendar
     * 
@return formated time string
     
*/
    
private static String getTime(Calendar calendar) {
        
return new StringBuffer()
                .append(calendar.get(Calendar.YEAR)).append(
"")
                .append(calendar.get(Calendar.MONTH) 
+ 1).append("")
                .append(calendar.get(Calendar.DAY_OF_MONTH)).append(
"日  ")
                .append(calendar.get(Calendar.HOUR_OF_DAY)).append(
"")
                .append(calendar.get(Calendar.MINUTE)).append(
"")
                .append(calendar.get(Calendar.SECOND)).append(
"")
                .toString();
    }

    
/**
     * 计算一天的时间间隔
     * 一天24小时×每小时60分×每分60秒×1000
     *
     * 
@return 一天时间
     
*/
    
private static long getPeriod() {
        
return 86400000;
    }
}

配置web.xml
    <servlet>
        
<servlet-name>luceneTimerServlet</servlet-name>
        
<servlet-class>sompackage.servlet.LuceneTimerServlet</servlet-class>
        
<load-on-startup>1</load-on-startup>
    
</servlet>


如果采用Listener,则是:
    <listener>    
        <listener-class>sompackage.servlet.LuceneTimerServlet</listener-class>
    
</listener>

posted @ 2006-03-08 12:42 martin xus| 编辑 收藏

名人,垃圾!

以前总在珠江路上看到名人专卖店,以为名人还不错,谁知道买了个电子词典,到家就花屏!

NND,骗子!以后肯定不会看名人的产品!

posted @ 2006-03-07 12:51 martin xus| 编辑 收藏

终究还是决定走了

走了,正在准备办理离职手续,心里总觉的有点点失落,也许我还真的对这个公司有点期盼,也许对自己的选择不是太满意,也许我没有做到我自己想做的事太多,也许什么都不是只是我的心情不好,走了,终究决定走了...

该去寻找我自己的天空去了,我不可这样堕落的活下去了,自己对自己得有个交代。

我看中了一家小公司,是我朋友的,我可以按我想法的去给公司开发成品,我可以用我最喜欢的技术,我可以做我任何想做的事,我自由了!

祝自己好运!

posted @ 2006-03-03 11:12 martin xus| 编辑 收藏

Lucene 1.9-final release available

From: Doug Cutting <cutting@apache.org>
To: java-user@lucene.apache.org
------------------------
Release 1.9-final of Lucene is now available from:

http://www.apache.org/dyn/closer.cgi/lucene/java/

This release has many improvements since release 1.4.3, including new
features, performance improvements, bug fixes, etc.  For details, see:

http://svn.apache.org/viewcvs.cgi/*checkout*/lucene/java/tags/lucene_1_9_final/CHANGES.txt

1.9 will be the last 1.x release. It is both back-compatible with 1.4.3
and forward-compatible with the upcoming 2.0 release. Many methods and
classes in 1.4.3 have been deprecated in 1.9 and will be removed in 2.0.
 Applications must compile against 1.9 without deprecation warnings
before they are compatible with 2.0.

Doug

posted @ 2006-03-02 09:12 martin xus| 编辑 收藏

仅列出标题
共28页: First 上一页 4 5 6 7 8 9 10 11 12 下一页 Last