后来

Posted by smily | 简单生活 | Saturday 25 October 2008 22:16

后来我发现,不是我身边的人变了,而是我变了。变得忍耐力强,变得对待事情不那么较真,变得害怕吵架,变得害怕哭泣,害怕那种由于情感的波动而导致身体的不适的可怕的感觉。

最后一根稻草

Posted by smily | 简单生活 | Saturday 25 October 2008 22:12

发现很多事情都是累积和惯性的结果,如果你认为他有某种恶习,那么除非他痛改前非的非常明显,才会在内心里消除掉不好的印象,否则,但凡有类似的恶习出现,则开始认为这人死不悔改。

心里难过,偷偷哭,委屈到极点的纵容自己的眼泪,不再想像年轻的时候,希望有人来安慰,因为,哭泣的目的很单纯,那就是告诉自己,我委屈了,需要哭泣,不想理智的告诉自己不要生气,也没法为了心疼眼睛而控制,所以,那就哭吧。很清楚自己在干什么,想干什么,那就这么做吧。

如果两个人亲近到说话可以肆无忌惮,那就危险了。

抓心挠肝

Posted by 猪头小队长 | 简单生活 | Thursday 23 October 2008 12:59

今天,他们那边的昨天,android开卖了
而寡人只能望洋兴叹

The DDMS of android 1.0 plugin for eclipse can’t works

Posted by 猪头小队长 | 程序设计 | Wednesday 22 October 2008 19:21

在安装了Android的SDK(1.0版)和为Eclipse安装完毕ADT插件之后,DDMS控制台没有打印出什么信息,在0.9版本的时候,没有遇到这个问题,不知道该怎么办。

临时的办法是:继续使用Eclipse来启动模拟器,直接使用sdk中提供的ddms来连接这个模拟器。也没有麻烦太多。但是发现ddms也启动不了:

12:43 E/ddms: shutting down due to uncaught exception
12:43 E/ddms: java.lang.UnsatisfiedLinkError:
/data/programs/android/android-sdk-linux_x86-1.0_r1/tools/lib/libswt-pi-gtk-3232.so:
/data/programs/android/android-sdk-linux_x86-1.0_r1/tools/lib/libswt-pi-gtk-3232.so:
wrong ELF class: ELFCLASS32 (Possible cause: architecture word width
mismatch)
    at java.lang.ClassLoader$NativeLibrary.load(Native Method)
    at java.lang.ClassLoader.loadLibrary0(ClassLoader.java:1751)
    at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1660)
    at java.lang.Runtime.loadLibrary0(Runtime.java:822)
    at java.lang.System.loadLibrary(System.java:993)
    at org.eclipse.swt.internal.Library.loadLibrary(Library.java:123)
    at org.eclipse.swt.internal.gtk.OS.<clinit>(OS.java:22)
    at org.eclipse.swt.internal.Converter.wcsToMbcs(Converter.java:63)
    at org.eclipse.swt.internal.Converter.wcsToMbcs(Converter.java:54)
    at org.eclipse.swt.widgets.Display.<clinit>(Display.java:126)
    at com.android.ddms.UIThread.runUI(UIThread.java:329)
    at com.android.ddms.Main.main(Main.java:97)

原因大概是android sdk不是for x86_64版本的,所以从Eclipse那里下载swt-3.2-gtk-linux-x86_64.zip,解压缩后覆盖tools/lib下的那几个文件,就可以启动了。

 

一个人

Posted by smily | 简单生活 | Tuesday 21 October 2008 17:49

早上上班的路上看到一个同事:白衣服,浅蓝色仔裤,运动鞋,左手一个魔方,右手笔记本包,头发稍显凌乱,皮肤白皙。于是,知道了他为什么可以闭眼的玩转魔方。功夫不负有心人。

Posted by smily | 简单生活 | Tuesday 21 October 2008 10:27

好多天了,什么都写不出来,脑子空空,想好好珍惜这几天,难得的。到底在追求改变还是不变,不清楚,奇怪的人,奇怪的思想,奇怪的想念,奇怪的理论,奇怪的时间,奇怪的愤怒,奇怪的奇怪的。

Spring与DWR集成的两种配置方式

Posted by 猪头小队长 | 程序设计 | Tuesday 14 October 2008 18:02

关于Ajax的框架,以前用的是Buffalo,但是DWR比较热,于是配置一下DWR玩一玩。现在的形势是:无论弄个什么框架,如果不和Spring集成一下,都不好意思跟别人打招呼。

在这里使用的Spring和DWR都是最新的版本:
Spring版本: 2.5.5
DWR版本:2.0.5

首先来一个测试页面,这是一个静态页面,在这个页面中调用java.util.Date的toString()方法。使用java.util.Date比较简单,这样除了用到了Spring和DWR的类库外,不用写任何Java代码既可以达到演示的目的。

<html>
<head>
  <title>www.simplelife.cn</title>
  <script type=’text/javascript’ src=’dwr/interface/javaDate.js’></script>
  <script type=’text/javascript’ src=’dwr/engine.js’></script>
  <script type=’text/javascript’ src=’dwr/util.js’></script>
</head>

<body>
<input type=’button’ on-click=’javaDate.toString(reply);’ value=’show time’/>

<script type=’text/javascript’>
    var reply = function(data)
    {
      if (data != null && typeof data == ’object’) 
        alert(dwr.util.toDescriptiveString(data, 2));
      else 
        dwr.util.setValue(’d0′, dwr.util.toDescriptiveString(data, 1));
    }
</script>
<br>
<span id=’d0′></span>
</body>
</html>

接下来有两种配置Spring与DWR集成的方式:

第一种配置方式
在这种方式中,不需要dwr.xml文件,将这部分配置与Spring的配置写在同一个文件中。DWR使用的servlet为:org.directwebremoting.spring.DwrSpringServlet,这样,只需要两个配置文件就可以了,分别是:

web.xml:

<?xml version="1.0" encoding="ISO-8859-1"?>
<!DOCTYPE web-app PUBLIC
    "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
    "http://java.sun.com/dtd/web-app_2_3.dtd">

<web-app id="simplelife.cn">
  <context-param>
    <param-name>contextConfigLocation</param-name>
    <param-value>/WEB-INF/applicationContext.xml</param-value>
  </context-param>
  <listener>
    <listener-
class>
      org.springframework.web.context.ContextLoaderListener
    </listener-
class>
  </listener>

  <servlet>
    <servlet-name>dwr-invoker</servlet-name>
    <display-name>DWR Servlet</display-name>
    <description>Direct Web Remoter Servlet</description>
    <servlet-class>org.directwebremoting.spring.DwrSpringServlet</servlet-class>

    <!– This should NEVER be present in live –>
    <init-param>
      <param-name>debug</param-name>
      <param-value>true</param-value>
    </init-param>

    <!– Remove this unless you want to use active function reverse() {
[native code]
} ajax –>
    <init-param>
      <param-name>activeReverseAjaxEnabled</param-name>
      <param-value>true</param-value>
    </init-param>

    <!– By default DWR creates application scope objects when they are first
    used. This creates them when the app-server is started –>
    <init-param>
      <param-name>initApplicationScopeCreatorsAtStartup</param-name>
      <param-value>true</param-value>
    </init-param>

    <!– This enables full streaming mode. It’s probably better to leave this
    out if you are running across the internet –>
    <init-param>
      <param-name>maxWaitAfterWrite</param-name>
      <param-value>-1</param-value>
    </init-param>

    <!–
    For more information on these parameters, see:
    - http://getahead.org/dwr/server/servlet
    - http://getahead.org/dwr/function reverse() {
[native code]
}-ajax/configuration
    –>
    <load-on-startup>1</load-on-startup>
  </servlet>

  <servlet-mapping>
    <servlet-name>dwr-invoker</servlet-name>
    <url-pattern>/dwr/*</url-pattern>
  </servlet-mapping>
</web-app>

 
另外一个文件是applicationContext.xml文件:

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xmlns:p="http://www.springframework.org/schema/p"
       xmlns:dwr="http://www.directwebremoting.org/schema/spring-dwr"
       xmlns:context="http://www.springframework.org/schema/context"
       xsi:schemaLocation="http://www.springframework.org/schema/beans
                           http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
                           http://www.directwebremoting.org/schema/spring-dwr
                           http://www.directwebremoting.org/schema/spring-dwr-2.0.xsd

                           http://www.springframework.org/schema/context
                           http://www.springframework.org/schema/context/spring-context-2.5.xsd">

  <bean id="dwrJavaDate" class="java.util.Date">
    <dwr:remote javascript="javaDate">
    </dwr:remote>

  </bean>

  <dwr:configuration></dwr:configuration>
  <dwr:controller id="dwrController" debug="true" />
</beans>

注意配置文件中的黑体部分。

第二种配置方式
使用第一种方式的Spring配置文件看起来比较乱,不那么干净,在这种方式中,将Spring的配置与DWR的配置完全分开,看起来干净利落。DWR使用的servlet为:org.directwebremoting.servlet.DwrServlet ,这样就需要三个配置文件了:

 web.xml文件:

<?xml version="1.0" encoding="ISO-8859-1"?>
<!DOCTYPE web-app PUBLIC
    "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
    "http://java.sun.com/dtd/web-app_2_3.dtd">

<web-app id="simplelife.cn">

  <context-param>
    <param-name>contextConfigLocation</param-name>
    <param-value>/WEB-INF/applicationContext.xml</param-value>
  </context-param>
 <listener>
     <listener-
class>
         org.springframework.web.context.ContextLoaderListener
     </listener-
class>
 </listener>

  <servlet>
    <servlet-name>dwr-invoker</servlet-name>
    <display-name>DWR Servlet</display-name>
    <description>Direct Web Remoter Servlet</description>
    <servlet-class>org.directwebremoting.servlet.DwrServlet</servlet-class>

    <!– This should NEVER be present in live –>
    <init-param>
      <param-name>debug</param-name>
      <param-value>true</param-value>
    </init-param>

    <!– Remove this unless you want to use active function reverse() {
[native code]
} ajax –>
    <init-param>
      <param-name>activeReverseAjaxEnabled</param-name>
      <param-value>true</param-value>
    </init-param>

    <!– By default DWR creates application scope objects when they are first
    used. This creates them when the app-server is started –>
    <init-param>
      <param-name>initApplicationScopeCreatorsAtStartup</param-name>
      <param-value>true</param-value>
    </init-param>

    <!– This enables full streaming mode. It’s probably better to leave this
    out if you are running across the internet –>
    <init-param>
      <param-name>maxWaitAfterWrite</param-name>
      <param-value>-1</param-value>
    </init-param>

    <!–
    For more information on these parameters, see:
    - http://getahead.org/dwr/server/servlet
    - http://getahead.org/dwr/function reverse() {
[native code]
}-ajax/configuration
    –>
    <load-on-startup>1</load-on-startup>
  </servlet>

  <servlet-mapping>
    <servlet-name>dwr-invoker</servlet-name>
    <url-pattern>/dwr/*</url-pattern>
  </servlet-mapping>

</web-app>

 applicationContext.xml文件,这是一个纯粹的Spring配置文件:

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xmlns:p="http://www.springframework.org/schema/p"
       xmlns:context="http://www.springframework.org/schema/context"
       xsi:schemaLocation="http://www.springframework.org/schema/beans
                           http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
                           http://www.springframework.org/schema/context
                           http://www.springframework.org/schema/context/spring-context-2.5.xsd">
  
  <bean id="dwrJavaDate" class="java.util.Date">
  </bean>
</beans>

  最后一个文件是dwr.xml,在这个文件中,使用spring容器中的对象:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE dwr PUBLIC "-//GetAhead Limited//DTD Direct Web Remoting 2.0//EN" 
  "http://getahead.org/dwr/dwr20.dtd">
<dwr>
  <allow>
    <create creator="spring" javascript="javaDate">
      <param name="beanName" value="dwrJavaDate"/>
    </create>

  </allow>
</dwr>

 

以上两种方式都可以完成Spring与DWR的集成,我比较喜欢第二种,“上帝的归上帝,恺撒的归恺撒”。
如果再需要配置MVC等其他功能,直接在web.xml中声明另外的Servlet即可,就合DWR没什么关系了。

 附录:目录结构

javor@desktop:/data/servers/apache-tomcat-5.5.25/webapps/simplelife$ ls -l
-rw-r–r– 1 javor javor  663 2008-10-14 16:58 index.html
drwxr-xr-x 3 javor javor 4096 2008-10-14 17:52 WEB-INF
javor@desktop:/data/servers/apache-tomcat-5.5.25/webapps/simplelife$ ls -l WEB-INF/lib
total 12076
-rw-r–r– 1 javor javor  188671 2008-10-14 16:36 commons-beanutils.jar
-rw-r–r– 1 javor javor  571259 2008-10-14 16:36 commons-collections.jar
-rw-r–r– 1 javor javor  121757 2008-10-14 16:36 commons-dbcp.jar
-rw-r–r– 1 javor javor   38015 2008-10-14 16:36 commons-logging-1.0.4.jar
-rw-r–r– 1 javor javor   60841 2008-10-14 16:36 commons-logging.jar
-rw-r–r– 1 javor javor   62103 2008-10-14 16:36 commons-pool.jar
-rw-r–r– 1 javor javor   84462 2008-10-14 16:36 commons-validator-1.1.4.jar
-rw-r–r– 1 javor javor   84462 2008-10-14 16:36 commons-validator.jar
-rw-r–r– 1 javor javor  502402 2008-10-14 16:36 dwr.jar
-rw-r–r– 1 javor javor   65261 2008-10-14 16:36 jakarta-oro-2.0.8.jar
-rw-r–r– 1 javor javor  358085 2008-10-14 16:36 log4j-1.2.12.jar
-rw-r–r– 1 javor javor 2949316 2008-10-14 16:36 spring.jar
-rw-r–r– 1 javor javor  404466 2008-10-14 16:36 spring-webmvc.jar
-rw-r–r– 1 javor javor  393259 2008-10-14 16:36 standard.jar

 [END]

天道

Posted by smily | 简单生活 | Sunday 12 October 2008 20:49

周末看了几集电视剧,主演是王志文和左小青,剧名叫《天道》,最大的特点是台词深奥和感动。记得几句:
1.如果你知道你是谁,你就不是你了;如果你不知道你是谁,你才是你。
2.就希望躺在你的怀里,悄悄的死去,然后你把我撒向大海。
3.我的坟头会开着很多小小的勿忘我,然后你拿着一只花走向坟头,两行泪水从你的眼中流下。

鄙Mysql5.1的defaults-file

Posted by 猪头小队长 | 程序设计 | Friday 10 October 2008 10:40

为了试验Mysql的分区功能,所以下载了mysql-5.1.28-rc-linux-x86_64-glibc23.tar.gz,Mysql自5.1起才开始提供partition的功能,只不过现在还是rc版,并且这个特性一直都是试验性质的,not production-ready。最喜欢的就是tar.gz这种形式的二进制软件包了,不需要安装,解开压缩就可以用,data目录等都在当前目录下,很方便。

可是用这个5.1的时候,就出了一些小麻烦:

javor@desktop:/data/programs$ tar zxvf mysql-5.1.28-rc-linux-x86_64-glibc23.tar
javor@desktop:/data/programs$ ln -s mysql-5.1.28-rc-linux-x86_64-glibc23 mysql
javor@javor-desktop:/data/programs$ cd mysql
javor@desktop:/data/programs/mysql$ scripts/mysql_install_db

FATAL ERROR: Could not find /fill_help_tables.sql

If you compiled from source, you need to run ’make install’ to
copy the software into the correct location ready for operation.

If you are using a binary release, you must either be at the top
level of the extracted archive, or pass the –basedir option
pointing to that location.

javor@desktop:/data/programs/mysql$

还可能出现一些其他的错误:

081010 10:52:05 [ERROR] Can’t find messagefile ’/usr/share/mysql/english/errmsg.sys’
081010 10:52:05 [ERROR] /data/programs/mysql/bin/mysqld: unknown option ’–skip-bdb’

解决办法:

javor@desktop:/data/programs/mysql$ scripts/mysql_install_db \
–defaults-file=/etc/my.cnf \
–basedir=/data/programs/mysql \
–datadir=/data/programs/mysql/data \
–user=javor


同样,在启动Mysql服务的时候:

javor@desktop:/data/programs/mysql$ bin/mysqld_safe \
–defaults-file=/etc/my.cnf \
–basedir=/data/programs/mysql \
–datadir=/data/programs/mysql/data \
–user=javor

在进入mysql client的时候使用同样的方式。

娃哈哈呀娃哈哈,每个人脸上都笑开颜

Posted by 猪头小队长 | 简单生活 | Thursday 9 October 2008 18:07

近期发生了两件大事:

  1. 从房客沦为房奴

    • 鬼知道这应该是什么心情,站在空空的屋子里面,看着刚刚粉刷过的墙壁,这就是家吧?心中不免感慨。我们已经为了它奋斗了一些年,我们还要为了它继续奋斗很多年。
    • 趁着十一黄金周苏宁促销,几乎花光了最后一分钱。:),看着家里面的东西渐渐齐全,还是不知道是什么心情,这就是家吧?
    • 从此,城铁将是我每天的必修课了,无法想象哪一天城铁不运转会是一个什么情况。
  2. 参加电源在四川的婚礼
    • 即使从一个男人的角度来看,电源的婚礼搞的也很罗曼蒂克,具体到什么程度,参看照片(照片在哪里?)。
    • 几只猪聚在一起,奇怪的是,无论相隔多么长的时间见面,见到一起扯淡都能扯的那么心有灵犀。
    • 川菜挺辣的,辣完了之后有两种后果,要么拉,要么不拉,都很有意思。
    • 泸州特别美的美女不多,但是不美的美女没有,也就是说平均分非常高,也可能是因为美女太多了,相比较之下,就感觉没有绝色美女了,不像在北京,见到一个敢暴露的,都会大呼小叫一番。
    • 泸州老窖真他妈好喝!
    • 重庆的“老麻抄手”够麻,吃过之后喝一口水,感觉舌头上像涂了一层蜡一样。
Next Page »