Aug 23
Compass是对lucene进行封装的java项目,使得在spring,hibernate这种环境下非常容易的实现全文检索,也极大的提高了效率。所以在myblog里面我也使用了compass作为全文索引。
从Compass的samples里面的petclinic里面可以找到Compass的配置。
<bean id="compass" class="org.compass.spring.LocalCompassBean">
<property name="resourceLocations">
<list>
&...
[more..]
Oct 22
我们的项目用到了xmlrpc,不过还是用的2.x版本的。由于xmlrpc3.x地推出。提供了NULL,Serializable等的支持,将原来的Hashtable改成了Map,Vector改成了List。都是不错的进步。所以我们决定从xmlrpc2.x升级到xmlrpc3.x. 在spring里面有几个ServiceExporter,org.springframework.remoting.rmi.RmiServiceExporter、org.springframework.remoting.caucho.HessianServiceExporter、org.springframework.remoting.caucho.BurlapServiceExporter。不过没有xmlrpc的serviceExporter,原来我们是自己封装的XmlRpcServer,用servlet提供服务。(eg:http://localhost:8080/community/service/xmlr...
[more..]
Aug 10
jspark 的这篇文章《 开发阶段eclipse下面的spring容器的启动优化 》讲到如何加快spring的启动速度。非常感谢 jspark. 一下是引用的原文: 最近在负责一个大项目,项目组成员包括项目经理大概10个人左右。项目技术用struts+spring+hibernate实现。项目的规模相对来说是比较大的,总共有10大模块,每个大模块又分为有十几个、甚至几十个小模块。开发工具用eclipse,由于在开发阶段,项目开发成员需要频繁重启服务器。在启动服务器的时候,每次启动时间总是会超过1分钟。记得以前在做另外一个项目时,启动时间不到5秒钟,相差了10倍,而且项目规模是差不多的。 从初步分析来说,应该是hibernate解释hbm.xml时花费时间,或者可能是spring容器启动并解释所有的bean配置文件。诊断了一下,发现1分钟消耗的时间主要分布在hibernate解释hbm.xml花费5秒;spring容器从启动到解释bean配置文件竟然花了...
[more..]
Jun 14
Templates based mailers
Let's define an interface for mailers based on a template engine (such as Velocity and FreeMarker).
import java.util.Map; import java.util.List; public interface TemplateMailer { /** * Send a mail with both a text and a HTML version. * @param email the email address where to send the email * @param context a {@link Map} of objects to expose to the template engine * @param templatePrefix the prefix of the templates to use */ void mail(...
[more..]
Jun 11
在以前的项目中对于一些资源的配置基本上都是通过spring的IOC注入一个目录的地址字符串。而这样的问题是,对于开发中的团队来说还是很有问题的,因为每个可能都配置一个不同的本地目录,而发布到服务器之后又有不同的目录。这样造成每个人提交了配置文件之后其他人都可能需要修改配置文件才能正确启动服务。这确实很令人烦劳。 最近看《Professional Java Development with the Spring Framework》时看到了spring对底层资源的抽象,才找到了完美解决方案。 原来的代码: private String templatePath; public void setTemplatePath(String templatePath) {  ...
[more..]
May 26
现在的系统中虽然使用了。Hibernate但是没有使用Hibernate的关联关系来进行数据库操作。所有的管理操作都是单独实现的。所以也不能用Criteria.add()这种方式去查询关联的一方。所以只能用Native SQL去查询结果返回对象了。按照Hibernate3的reference里面说的 16.1.?使用 SQLQuery 对原生SQL查询执行的控制是通过 SQLQuery 接口进行的,通过执行 Session.createSQLQuery() 获取这个接口。最简单的情况下,我们可以采用以下形式: List cats = sess.createSQLQuery("select * from cats") .addEntity(Cat.class) .list(); 这个查询指定了: SQL查询字符串 查询返回的实体 这里,结果集字段名被假设为与映射文件中指明的字段名相同。...
[more..]