Javava

爪哇岛的一个山洼。

2007-05-18

【那好吧】网站开通了,欢迎大家前去体验。

那好吧网站,提供了一个非常方便操作的相册。

提供了在线同时编辑多张图片,创作连环故事的功能。

2007-04-25

【2007年4月25日】和一个朋友在Email中讨论AndroMDA的内容

Question 1: In chapter 4, is it better to name CarManager instead of
CarManagerController? Is it clearer "换句话说,CarManager是用来在Struts的Action
中调用。在Struts中之所以将Action和CarManager分离出来,主要是让开发者专注于
业务逻辑的开发,而避开Action配置的Controller技术细节"。Because Controller has
special meaning in Struts' MVC model. It is ease to be confused as a reader.

I thought uses Controller the name quite to be good. The Controller expressed in Struts
MVC in fact is the model Controller, therefore cannot have the confusion.

In the androMDA documents, has the following description to struts:
------------------------------

------------------------------
Struts

In order to adhere to the spirit of Struts web development I am trying to attain
at least the same strict requirements of its MVC implementation. As opposed to
earlier version of this cartridge, you will only need to model the Controller class,
the Views and Models are implied by the dynamic processes.

Model

The model corresponds to the form bean used in the request, this bean encapsulates
all request parameters for the use-case. No more logic should be put in there. Models
are generated by looking at the parameters sent between action states.

View

In a Struts application you will use JSP pages to represent the view components.
In the application's activity graphs views are tagged with the 'FrontEndView''
stereotype.

Controller

A Controller class defines the business operations performed by the actions on the
front-end. Typically it is the user who triggers an event by clicking on a button
or an hyperlink, this event is handled by an action that will defer any business
operation to the controller.
------------------------------------------------------------


Question 2: Assume project size is 50 developers for 18 months.
60% is for back-end business logic, 30 EJB developers.
20% front-end GUI, 10 web developers, and 10% for database system, 5 engineers
as well as 10% for messaging middleware.
How difficult to define Velocity templates for median or above size project?
How difficult to maintain the Velocity templates for the project during it's life cycle?
Velocity template is based on the concept of "macro" which is notorious for
maintenance?
Is the cost of learning AndroMDA such as the complexities of configuration
worthy for over-all project supports?

AndroMDA is auxiliary means, has the very many plug-in unitscomposition (Cartridges),
also may develop own plug-in unit(Cartridges). Chooses the suitable plug-in unit
and the use in the project in theappropriate place, enhances the working efficiency.
At present said, total dependence one code production tool is not realistic.

1. Because uses the Velocity definition the templates is one kind of code
structure plan, is provides in AndroMDA default approves in situation which the
templates does not answer the purpose, own redefine, in the ordinary
circumstances revises the original templates line. In several actual project, I
basically has all used the templates which default approved, has only made the
small change. Therefore defines the Velocity templates not to be certainly difficult.

2. The Velocity templates has nothing to do with with the actual project business
logic, therefore so long as just was starting planned after, during project's life
cycle, It does not have the frequent revision after define good set of Velocity,
but also may entrust with heavy responsibility in many projects. Therefore,
Velocity templates certainly not be major problem.

3. As for the beginner, androMDA disposition quite complex, but basically all has
default approves the establishment, very easy seat of honor. To AndroMDA use more
skilled after, can think the disposition structure is very clear. Studies AndroMDA
the cost to belong to the disposable cost, after is familiar may in many projects
uses, moreover is studying and appraised other similar MDA tool time is easier.
I thought studies AndroMDA is worth very much.

Recently, my manager has recommended a new MDA tool to me, calls Acceleo
( http://www.acceleo.org), based on Eclipse and EMF framework, is easier to study
and the use. I donot have the time to study, if you are interested, you can go
have a look.

2007-04-03

【技术心得】遇到技术难题一筹莫展的时候你该做什么?

一筹莫展??如果你正遇到一个技术问题可以用这四个字来形容的话,给你一个万能的解决方法:

public static void 万能解决方法()
{
  boolean 问题解决 = false;

  // 先仔细搜索互联网或者相关技术支持论坛,查看别人是否遇到过类型问题
  google.search();

  // 耐心查阅帮助文档的相关部分100遍,直到问题解决
  for(int i=0; i<100; i++)
  {
    阅读帮助文档;
    if(发现解决办法)
    {
      问题解决 = true;
      break;
    }
  }

  // 如果问题还没有解决,到技术支持论坛发问
  if(!问题解决)
  {
    try
    {
      askQuestion();
    } finally
    {
      thanks();
    }
  }

  // 如果还没有解决,可能就是因为你的基础知识不够,请拿出耐心仔细学习基础
  if(!问题解决 && You.struggling())
  {
    if(学习到解决问题的知识)
    {
      return;
    }
  } else
  {
    // 退出江湖
    quitRiversAndLakes();
  }
}

【技术转载】选择select的当前选项触发onchange事件

我们用Select的onchange事件时,常会遇到这样一个问题,那就是连续选相同一项时,不触发onchange事件.select的onchange事件就是这样子的.你得有Change(改变),才能触发该事件....

掌握了它的特性后,相应的解决办法也很简单.

<select name=sel onchange="bao(this.options[this.options.selectedIndex].value)">
<option value="">请选择
<option value="1">Item 1
<option value="2">Item 2
<option value="3">Item 3
</select>
<script>
function bao(s)
{
txt.value+=s;
//选择后,让第一项被选中,这样,就有Change啦.
document.all.sel.options[0].selected=true;
}
</script>
<textarea id=txt></textarea>

2007-03-29

【技术心得】2007-03-29 凌晨解决 linux 中 java 对中文宋体的支持

2007-03-29 凌晨解决 linux 中 java 对中文宋体的支持

问题产生:我配置在linux上的tomcat服务器生成图片时中文,出现很多小方框,不能正常显示。
问题解决过程:通过网络上搜索资料,发现是因为linux上jre对中文支持的问题。后来发现这篇小文章:
----------------------------------------------------------------------------------------------
JDK 6 for linux的中文问题
在linux下做java开发已经好几年了,经历了jdk1.4 -> 6.0。看着java在linux下的中文问题已经在慢慢改善。到6.0不做任配置都已经能正常运行很多中文程序,但可惜还是会有些中文问题。例如运行 jedit, netbeans等程序。甚至是自己写的hello world swing程序的系统菜单都是乱码的。
但解决方法很简单,在JRE 5以上的java环境中,java会自动加载$JAVA_HOME/jre/lib/fonts/fallback目录下的字体。链接或复制宋体或微软雅黑等字体到该目录即可解决。
但官方文档上说此法只适用于swing程序,要让awt程序也支持中文,还要自己设字体配置文件。由于我很少会用到awt程序,也就懒得去改了,有需要的朋友请参考Font Configuration Files
----------------------------------------------------------------------------------------------
感谢这篇文章的作者,虽然语言不多,但对不知情者很有价值。我按照其中的这句话:
在JRE 5以上的java环境中,java会自动加载$JAVA_HOME/jre/lib/fonts/fallback目录下的字体。链接或复制宋体或微软雅黑等字体到该目录即可解决。
进行操作:
在Windows XP的字体目录下,找到simsun.ttc的字体文件,重命名为simsun.ttf,然后将该文件复制到linux的/usr/local/jdk/jre/lib/fonts/fallback/(这个fallback目录如果不存在则先创建这个目录)下面,因为 simsun.ttf 字体文件对应的是宋体,则在程序中使用的时候设置字体为“宋体”。重新启动tomcat服务,运行程序,中文正确显示。该问题解决。

由于本人之前对linux系统不熟悉,遇到这样的未知问题,但通过搜索资料,很快便解决了这个问题。

2007-03-28

【技术心得】2007-03-28 整理 mysql 在 linux 上面设置中文字符集

2007-03-28 整理 mysql 在 linux 上面设置中文字符集

先从 /usr/local/mysql/support-files/ 目录下面拷贝 my-huge.cnf 或者 my-large.cnf 或者 my-innodb-heavy-4G.cnf 或者 my-medium.cnf 或者 my-medium.cnf 或者 my-small.cnf 到 /etc/ 下面,并命名为 my.cnf,即 /etc/my.cnf(因为mysql默认会在 /etc/my.cnf 下面读取配置)。然后在 /etc/my.cnf 配置文件中加入中文字符的设置:

在[client]下面添加:
#---------------------------------------------------------------------------
# Add by widen on 2007-03-15
default-character-set=gbk
#---------------------------------------------------------------------------

然后在[mysqld]下面添加:
#---------------------------------------------------------------------------
# Add by widen on 2007-03-15
default-character-set=gbk
#---------------------------------------------------------------------------

重新启动mysql服务器,就可以生效了。

遇到mysql问题时的核心解决问题的方法:先到mysql的安装目录查找各种帮助性质的文件,如果不能找到有用信息,则查看mysql详细用户手册,或者到网上搜索相关问题。