• 2005年03月18日

    Ajax渐热

    Tag:Java
    最近在国外的blog看到Ajax出现的次数越来越多了,应用的例子也越来越多了,google的新东东,如google suggestgoogle map、gmail等都用了Ajax,看来会成为一个趋势了。

    Ajax是什么?
    Ajax是Jesse James Garrett在
    Ajax: A New Approach to Web Applications中先提出来的。
    引用:
    The name is shorthand for Asynchronous JavaScript + XML, and it represents a fundamental shift in what’s possible on the Web.

    Ajax isn’t a technology. It’s really several technologies, each flourishing in its own right, coming together in powerful new ways. Ajax incorporates:

    standards-based presentation using XHTML and CSS;
    dynamic display and interaction using the Document Object Model;
    data interchange and manipulation using XML and XSLT;
    asynchronous data retrieval using XMLHttpRequest;
    and JavaScript binding everything together


    Ajax的代码片段:http://www.fiftyfoureleven.com/resources/programming/xmlhttprequest/examples
  • MyEclipse是Eclipse中相当特殊的插件,安装它的话一定要看它是对应哪个版本的eclipse,如果版本不兼容的话会有相当多的问题的,如语法高亮丢失、打开XML文件出错等等。

    目前最新的MyEclipse的版本是3.8.4,是for eclipse 3.1M4的。

    又,eclipse 3.1M5a的性能不如3.1M4(网上有测试,个人感觉也如此),加上与MyEclipse的兼容性问题,不建议安装3.1M5a。

  • 2005年03月07日

    如何选择Cache组件?

    Tag:Java

            Java世界开源的好东东太多,享受高质量的选择的同时也常常面临抉择的痛苦。这不,要用一个Cache组件都是一个dilemma:Ehcache or OSCache?
           Ehcache出自Hibernate,后来才自立门户,不过,由于与Hibernate的血缘关系,自然是Hibernate的推荐cache了;而且acegi也用了Ehcache。然而OSCache是OpenSymphony(http://www.opensymphony.com)出品的,也自不凡(OS出品,必属精品:-)),而且OSCache还有一个WEB 组件 可以根据URL等缓存动态页面。
            如何选择?嗯,鱼与熊掌兼得最好了,Ehcache与OSCache并无任何的兼容性问题,就让它们各展所长好了:hibernate/acegi使用EhCache,而web页面缓存采用OSCache。

  • Tomcat5.0.X配置数据库连接池,是分别配置Resource和ResourceParams,如
    代码:
            <Resource name="jdbc/ExampleDB" auth="Container" type="javax.sql.DataSource"/>
              <ResourceParams name="jdbc/ExampleDB">
                <parameter>
                  <name>factory</name>
                  <value>org.apache.commons.dbcp.BasicDataSourceFactory</value>
                </parameter>
                <!-- Maximum number of dB connections in pool. Make sure you
                 configure your mysqld max_connections large enough to handle
                   all of your db connections. Set to 0 for no limit.
                -->
                <parameter>
                  <name>maxActive</name>
                  <value>100</value>
                </parameter>
                <!-- Maximum number of idle dB connections to retain in pool.
                     Set to 0 for no limit.
                     -->
                <parameter>
                  <name>maxIdle</name>
                  <value>30</value>
                </parameter>
                <!-- Maximum time to wait for a dB connection to become available
                     in ms, in this example 10 seconds. An Exception is thrown if
                     this timeout is exceeded.  Set to -1 to wait indefinitely.
                     -->
                <parameter>
                  <name>maxWait</name>
                  <value>10000</value>
                </parameter>
                <!-- MySQL dB username and password for dB connections  -->
                <parameter>
                  <name>username</name>
                  <value>root</value>
                </parameter>
                <parameter>
                  <name>password</name>
                  <value></value>
                </parameter>
                <!-- Class name for mm.mysql JDBC driver -->
                <parameter>
                  <name>driverClassName</name>
                  <value>com.mysql.jdbc.Driver</value>
                </parameter>
                <!-- The JDBC connection url for connecting to your MySQL dB.
                     The autoReconnect=true argument to the url makes sure that the
                     mm.mysql JDBC Driver will automatically reconnect if mysqld closed the
                     connection.  mysqld by default closes idle connections after 8 hours.
                     -->
                <parameter>
                  <name>url</name>
                  <value>jdbc:mysql://192.168.0.88:3306/quickoa</value>
                </parameter>
              </ResourceParams>

    而在Tomcat5.5.X中,这两者合二为一了,直接配置Resource就可以了,如
    代码:
    <Resource name="jdbc/ExampleDB" auth="Container"
          type="javax.sql.DataSource" driverClassName="com.mysql.jdbc.Driver"
          url="jdbc:mysql://localhost/quickoa" username="root"
          password="" maxActive="100" maxIdle="30" maxWait="10000" />

    又,值得注意的是在Tomcat5.5.X中,dbcp组件需要自己额外下载的,不像在Tomcat5.0.X中已经附带了。
  • 2005年01月28日

    Hibernate - XDoclet Tutorial

    Tag:Java

    http://www.downside.ch/hibernate/
    The tutorial covers the generation of Hibernate mapping files with XDoclet. If you are new to the Hibernate/XDoclet combo and want to have a glimpse into the world of ORM tools or you are just interested in some mapping examples then this is for you.