开源数据库mysql免费使用和商业使用的区别(转载)

今天,看到matrix的文章回复中有朋友问有什么开源付费的软件,我在网上找到这篇帖子,觉得很有代表性,特地转载于此。

转自:http://www.chinaunix.net/jh/17/814671.html 

转帖正文:

××××××××××××××××××××××××××××××××××××××××××××××××××××××××××

[保留] 【疑惑】mysql在商业上到底怎么用?需要付费么?别人告怎么办?

http://www.chinaunix.net 作者:jglxgz  发表于:2006-10-25 20:48:02

【发表评论】【查看原文】【MySQL讨论区】【关闭】

mysql到底怎么用了,需要付费么?包括服务器和客户端,windows和linux下的使用?在商业上怎么用了?别人告侵权咋办?

我现在打算用postgresql,但它缺乏windows下的双机热备

------------------------------------

下面的文章是转载(不好意思,找不到原始出处)

 ----------------------

很多人都不理解MySQL的授权方式,主要原因是没有中文资料别无其他!

我不想嘲笑谁,但是我认为有必要搞清楚这一重要的因素。国际官司我

们已经吃亏太多了,我不想这变成笑柄。

当前,MySQL采用双重授权(Dual Licensed),他们是GPL和MySQL AB

制定的商业许可协议。如果你在一个遵循GPL的自由(开源)项目中使

用MySQL,那么你可以遵循GPL协议使用MySQL。否则,你需要购买MySQL

AB制定的那个商业许可协议。这里最重要的一点就是要想免费使用MySQL,

你所开发的软件必须是遵循GPL的自由(开源)软件,虽然被批准的自由

(开源)许可协议有很多个。

理清授权管辖的范围

MySQL是一套客户端/服务器(C/S)结构的系统。双重许可机制对两大块

同时进行约束,但是并不绝对。MySQL AB(MySQL的出品公司)考虑到便

于人们使用,客户端是完全遵循GPL许可。也就是说,在事实上MySQL的

双重许可机制这一双重的特点是对服务器端而言的。我想,我恐怕会把

一些人搞糊涂,这里所说的客户端指的是MySQL AB开发的那个命令行下

的客户端工具(mysql.exe)。

不同操作系统下是否有特殊的限制?

在当前可以说没有,如果有只是MySQL具体代码实现上的功能差异,许

可协议本身是没有特定区分的。在早期MySQL确实对微软/非微软操作系

统进行过特定的区分,在那时如果要获得Windows平台最新的MySQL,

你必须付费购买,现在已经不同了。

Windows版本是否受到限制?

刚才已经说过了,现在没有这种区分,唯一的差异是不同操作系统下的

具体实现造成的。当前,你可以随意获得最新的Windows版本分发。他

们是没有功能、时间限制的。当然,你应该遵循许可协议。

以教育为目的是否需要付费?

其实没有这个区分,主要的取决还是软件是否遵循GPL进行发布。当然,

如果只是用来做课堂教学是不用购买商业许可协议,这种情况下MySQL

遵循GPL许可协议。

我该买几个许可证?

MySQL的许可证按照计算机台数计算,一台机器一个。至于一台机器多个

操作系统的情况下该购买几个许可证这种龌鹾问题别问我,我不知道!

许可证和技术支持的关系?!

技术支持和许可证是不同的东西。虽然很多的软件会把它们搭配销售,

但是实际上应该有单独签署一份技术支持保障协议。具体的时限和价格

我不清楚。

MySQL API的授权

MySQL客户端API遵循GPL协议,其中所包含的GNU getopt 遵循LGPL,并

且一些地方用到的regexp库则遵循BSD许可协议。

更多的信息

强烈建议去看看手册中MySQL许可协议的相关授权章节,里边写的非常详

细。

----------------------------------

欢迎释疑,谢谢!

 jglxgz 回复于:2006-08-20 21:16:41

http://www.mysql.com/company/legal/licensing/faq.html

 jglxgz 回复于:2006-08-20 21:17:48

http://www.mysql.com/company/legal/licensing/faq.html

-------------------------------------------------------------------------------

What is MySQL's software licensing model?

MySQL uses a "dual licensing" business model. Under this model, users may choose to use MySQL products under the free software/open source GNU General Public License (commonly known as the "GPL") or under a commercial license.

With the GPL license, MySQL is available free of charge. Users may download the software for free and modify, integrate and distribute it. However, GPL users must abide by the rules of the GPL, which stipulate that if a MySQL-based application is redistributed, the complete source code for this application must also be open and available for redistribution.

MySQL AB offers a commercial license for organizations that do not want to release the source code for their application. Commercial license customers get a commercially supported product with a level of assurance from MySQL AB, without the requirement that their MySQL-based software must be "open sourced". MySQL is able to provide a commercial license because it has full ownership of the MySQL code.

MySQL's dual licensing increases freedom in two ways: first, it encourages the growth of free software by licensing MySQL under the GPL; second, it makes it possible to use our software in situations where the GPL is not applicable.

Why does MySQL offer two licenses?

MySQL's dual license model supports the company's mission: to make superior database software available and affordable to all.

The dual licensing creates a circle that sustains both innovation and growth: MySQL channels the revenue from this viable open source business model back into support for its open source user community that, in turn, supports MySQL AB's commercial business.

Today, MySQL AB has over 4 thousand paying customers who have chosen the commercial license and over 4 million who have chosen the open source GPL license. The dual licensing business model is a "win-win" for all parties:

    * MySQL's open source community gets superior software for no cost;

    * MySQL's commercial customers have the option of using reliable, community "battle tested" MySQL software for a relatively low cost;

    * MySQL's business is healthy and viable, which also strengthens the open source movement.

How do I know which license to use?

The overall guiding business principle of MySQL's dual licensing is one of fair exchange or "Quid pro Quo" which means "something for something."

So if you use MySQL with GPL-licensed software (or a license that is GPL-compatible) we encourage you to use the GPL license. For all other users of MySQL, we recommend that you purchase a MySQL commercial license

For more complete guidelines on the GPL and commercial license from MySQL, please read our licensing overview or contact a MySQL representative online.

Do I get the same MySQL software under either license?

Yes. The MySQL product is essentially identical under either the GPL license or the commercial license. In some cases there are minor differences in the support libraries due to incompatibilities between the licenses of the libraries and MySQL.

How much does a commercial MySQL license cost?

As a result of its open source community and licensing model, MySQL AB is able to produce and offer its software at a much lower cost than what is typical in the industry. Current pricing for the server and other products can be found on our online store.

With a commercial license option, is MySQL still an "open source" company?

Yes, MySQL is still an open source company and is completely committed to the open source values and philosophy. We believe the open source model of development and distribution is the most efficient way to produce high-quality software. All MySQL software is offered under both open source and commercial license terms.

Are other companies using the dual licensing business model?

Yes, the dual licensing business model is becoming increasingly popular among open source companies as it paves the way for long-term financial viability. Other companies that offer dual licensing include Digium, OSAF, MandrakeSoft, Sleepycat Software, Technical Pursuit, Trolltech, and others.

Previously, the MySQL client libraries were licensed under the LGPL (the Lesser General Public License) and now they use the GPL (the General Public License). What prompted this change?

MySQL's goal is to provide all its software under a free software/open source license. The change from the LGPL to the GPL for the client libraries was made in 2001 during the development of MySQL 4.0 to help MySQL AB more easily differentiate between a proprietary user who should buy a commercial license and a free software user who should use the GPL license. Previously there were people that were misusing the GPL by distributing the MySQL server tightly coupled with their applications and claiming that the GPL doesn't affect them because the client libraries were free to use.

This change has allowed MySQL to support its dual licensing model by better identifying when someone is using MySQL software in a closed source fashion without commitment to the open source philosophy. While MySQL supports the open source ideals, we also believe in the notion of "Quid Pro Quo" or fair exchange. For developers building open source applications using MySQL, the change in the client licensing policy has no effect.

Based on feedback from our users, MySQL has introduced an exception that makes it possible to combine the MySQL client libraries with software that uses various Free and Open Source software ("FOSS") licenses. This is known as the FOSS License Exception.

What is the GPL License Exception for PHP?

Because PHP and MySQL use different incompatible open source licenses, we have created a special exception to encourage and promote the use of MySQL in the PHP community. MySQL AB gives permission to distribute derivative works that are formed with GPL-licensed MySQL software and with software licensed under version 3.0 of the PHP license. You must obey the GNU General Public License in all respects for all of the code used other than code licensed under version 3.0 of the PHP license.

There is also a more general exception which enables developers releasing software under other Free and Open Source software ("FOSS") licenses to include the MySQL client libraries. This is known as the FOSS License Exception.

What is the FOSS License Exception to the GPL?

The FOSS License Exception enables open source developers who are using Free and Open Source software ("FOSS") licenses other than the GPL to include the MySQL client libraries. Since some licenses are incompatible with the GPL this exception provides flexibility for open source developers. We want to support the open source community in their desire to use the MySQL client libraries in a broad range of open source projects.

Why has MySQL created the FOSS License Exception?

We created the FOSS License Exception to give developers greater flexibility in using MySQL with software that is under other Free and Open Source Software ("FOSS") licenses. Some open source licenses are not fully compatible with the GPL and so this exception makes it possible for developers to chose their preferred open source license and still have the ability to include the MySQL client libraries.

How did MySQL select the licenses for inclusion in the FOSS exception?

We have reviewed the most popular open source licenses to make sure that they can be used with the MySQL client libraries. If you are using a different open source license that follows the Open Source Definition by the Open Source Initiative and it is not on our list of approved licenses please contact us at license-feedback@mysql.com.

What is MySQL's policy on software patents?

We do not think that software patents are a useful way to protect software IP. Instead, we believe that copyright protection is sufficient. We have concluded that software patents are harmful to the software industry at large. This is why we support those who work for an abolishment of software patents. We also work with other companies and groups to build a joint defense against software patents. More information is available on our patent policy page.

How do I send MySQL AB comments on licensing or other issues?

The open source community is very important to MySQL and we want to hear all feedback! We have previously asked the community for specific feedback on licensing and will continue to do so to create an ongoing dialogue. You can send us your feedback using our feedback form. You can also fill out our survey on licensing and view the results.

Version 4.1, 12 March 2004

 michael75 回复于:2006-08-21 10:57:24

1、如果你是来开发一些应用软件,数据库用MYSQL,你所开发的应用软件销售,则需要付费license.如果你开发的软件不用于销售,但是你必须开放你的源码。如果你不开放源码,那么MYSQL公司就可以起诉你。

2、现在MYSQL的具体分类如下:pro版本分为windows、LINUX、UNIX操作系统, 其中windows、LINUX操作系统的MYSQL价格是一样的,UNIX操作系统的MYSQL贵一些。cluster版本的按照CPU来计算的。

3、如果你是用于商业,捆绑你公司产品销售,那么你必须购买MYSQL的license.根据你的需要的功能和操作系统,价格都会不一样。但是WINDOWS操作系统的价格都一样。

具体情况可以向我咨询:

**************************************************************  

             MYSQL AB中国研发中心

             拓林思(中国)软件有限公司(turboliunx.inc.

         北京万里开源有限公司      (greatlinux.inc)

                 

             宋桂平   MYSQL行业经理

            

地址:北京市朝阳区建国门外大街甲12号新华保险大厦5层503室

手机:13911253265

电话:010-65054020-315

传真:010-65054017

邮编:100022

邮件:michael.song@turbolinux.com.cn

网址:www.turbolinux.com.cn

**************************************************************

 ua 回复于:2006-08-21 12:14:39

如果用mysql作为数据库服务器开发了一些应用软件,仅供公司内部使用,如公司内部的一些小系统,应该是不收钱的,对吧?

 michael75 回复于:2006-08-21 14:27:05

这样的话是不收钱,但是你要开放你的应用软件的源码哦@!

 jglxgz 回复于:2006-08-21 15:15:12

引用:原帖由 michael75 于 2006-8-21 10:57 发表

1、如果你是来开发一些应用软件,数据库用MYSQL,你所开发的应用软件销售,则需要付费license.如果你开发的软件不用于销售,但是你必须开放你的源码。如果你不开放源码,那么MYSQL公司就可以起诉你。

2、现在MYS ...

-------------------

非常谢谢你的解答,你为何不在此贴一下一般的价格和服务支持情况了?很多人可能都有这方面的疑惑,他们即使想购买,可能都不知道怎么办。

也就是说mysql是一个基本商业化的软件,除了GPL用途外,但听说针对PHP有一个专门的许可,能否解释一下,谢谢!

 yejr 回复于:2006-08-21 16:06:55

嗯,解释解释

 jglxgz 回复于:2006-08-21 18:26:18

引用:原帖由 michael75 于 2006-8-21 10:57 发表

1、如果你是来开发一些应用软件,数据库用MYSQL,你所开发的应用软件销售,则需要付费license.如果你开发的软件不用于销售,但是你必须开放你的源码。如果你不开放源码,那么MYSQL公司就可以起诉你。

2、现在MYS ...

----------------------

网上找的,不知出处

开放源代码数据库公司MySQL已采取行动,避免MySQL数据库软件和好搭档PHP软件因授权问题硬生生被拆散。

  PHP全名是HypertextPreprocessor(超文件预处理器),昔日称作PersonalHomepage(个人首页),是一种开放源代码软件,其功能是让计算机快速建构特制的网页。Linux操作系统、Apache网页服务器、MySQL和PHP软件经常搭配使用,于是有开放源代码LAMP的称呼,代表这四种软件英文名起首字母的缩写。

  MySQL营销副总裁ZackUrlocker说,该公司上周四(11日)晚间已推出一项授权特例,允许PHP恢复昔日的做法,也就是与MySQL的组件──即所谓链接库(libraries)──绑在一起。

  PHP程序语言工具制造商Zend公司技术部副总裁AndiGutmans说,MySQL的举动“朝正确方向迈出的一步”,有助于解决开放源代码社区内部日益浮出台面的授权问题。

  和Sleepycat、Trolltech这些开放源代码软件公司一样,MySQL也采取一种策略,让自家的软件以双重管道散布,也就是一方面按开放源代码授权方式提供程序供开放源代码软件使用,同时也根据商业授权允许自制程式纳入专属软件之中。这种双重授权的做法──只适用于同一家公司握有全部源代码著作权的情况──据称有让营收加倍的效果。

  以MySQL为例,这家瑞典公司的数据库软件及支持的链接库现在采用公众通用证书(GPL)授权方式。但这些链接库先前是受次级公众通用证书(LGPL)的授权规范。

  两种授权方式之间的主要差异,在于专属软件或其它非GPL软件可能与LGPL软件有密切的关联。

  在去年6月以前,PHP软件一直纳入MySQL的链接库,让PHP程序设计师在构建网站时能够轻松利用数据库。但后来MySQL以某些专属软件开发商不当使用MySQL软件为由,改变了授权方式,让商业软件商必须付费取得MySQL商业授权,却也连带迫使PHP制造商移除MySQL组件,并且在后来推出的新PHP测试版中改搭配另一种数据库软件,称为SQLite,连红帽(RedHat)等公司也被迫必须更新软件。

  这些问题现在必须解决,Urlocker说。因为MySQL源代码全为MySQL公司所有,所以该公司可在自家软件中纳入额外的授权条款,新条款称为“免费和开放源代码的软件授权特例”,“让人们依循GPL以外的其它开放源代码授权许可,把MySQL客户端链接库与其它开放源代码计划搭配使用”。

  此特例条款“令人振奋”,Gutmans说。但他指出,MySQL还必须解决别的争议性问题,比方说另外再实施一个授权条款,允许专属软件链接库与MySQL的链接库并用。

--------------------------------------

这是另外一个:http://www.wzdjg.com/bbs/simple/index.php?t75.html

早前Zend给出了一些站不住叫的说法,早前就意识到是许可证的问题,这不,有人捅出来了:

  一直以来, MySQL公司采用的都是“双重”的授权方式,顾客可以在2种授权方式间任意选择。一种是在GPL (GNU General Public License)授权协议下可以免费使用,另一种是商用授权。但不久之后MySQL就表示有不少私有版权软件公司不恰当的使用了GLP授权许可证,因此对许可证的发放方式进行了修改并相应的更改了库文件的一些代码。

  MySQL公司此举遭到开源社区的强烈抗议之后,程序员们普遍认为这将会破坏MySQL数据库与其它软件包之间原有的紧密联系,世界著名的开放源代码数据库软件公司MySQL终于开始采取措施来弥补这个过失。

  在目前,LAMP(Linux、Apache、MySQL、PHP)Web服务应用构筑环境在业内得到了最广泛的应用。因此任何破坏这个应用架构的行为都将引起业界的反对。MySQL公司也是从善如流,在本周四又公布了一个特别许可证,允许PHP重新集成MySQL数据库的一些组件。

  专门从事PHP编程工具销售的技术公司Zend的副主席Andi Gutmans对记者表示,MySQL公司发布这个特别许可证是在正确的方向上前进了一步,而且残存的一些相关的问题也将在不久的将来得到解决。

  在MySQL公司公布新的许可证政策并对其软件的库文件进行修改之前,PHP程序员们可以很容易的利用MySQL数据库来构建网站。 Gutmans如是说,库文件的改变并不意味着PHP不能与MySQL数据库协同工作,不过确实没有以前那么方便了,现在使用MySQL与使用 Oracle或 PostgreSQL公司的数据库已经没有什么不一样了。

 业内人士则称这件事反映了开源软件在向主流迈进的过程中不可避免的阵痛。如果说此前闹得满城风雨的SCO所谓的版权官司是开源社区的软件共享哲学与私有版权软件世界的摩擦的升级的话,那么这次的MySQL许可证事件则表明在开源社区内部也产生了不和谐的声音。

  据记者最新得到的消息,在稍后时间将会公布的一个最新的PHP版本中,将不会集成MySQL的数据库,而是一个名为SQLite的数据库。开源软件巨头 Red Hat公司的发言人Leigh Day在早些时候也已经表示在将来的Linux系统中将不会有MySQL的位置,但其强调这与许可证问题无关。

  相对于共享软件与私有软件的冲突,开源社区内部的矛盾则要更加的复杂。一些分析家认为在下周于旧金山举行的开源社区商业大会上将会有更多的内部矛盾露出水面,预期届时MySQL公司将会大力吹捧它的新型许可证政策并对PHP进行攻击。

--------------------

怎么解释了,现在用mysql的确存在一些疑问

 michael75 回复于:2006-08-22 13:51:58

一、|关于商业MYSQL的购买价格指南:

Material Description                       License Type                          User Number         List Price         Support

MySQL  PRO Version

(for Linux和windows)                                     Server                                1           21,000.00               12

MySQL  PRO Version

(for   Unix)                                                      Server                                1           42,000.00              12

MY SQL   Classic Version

(for Linux和windows)                                      Server                                1           11,000.00               12

MY SQL  Cluster Version                                     Cpu                                 1           180,000.00               12

备注:1、以上价格为人民币;具体购买报价根据用户需求数量的多少享受不同级别的折扣. 2、服务期限为:12个月。3、版本之间的区别: Classic Version不带事务处理功能,PRO Version带事务处理功能,Cluster Version是做集群用的。

二、|MYSQL的支持与服务:

1、对社区下载的产品不提供任何服务与支持,出现问题可以向社区论坛寻求解决办法,但是响应速度慢,而且无法得到有力的支持,无可靠保障.

2、商业版MySQL服务与支持:

服务方式:远程支持,通过电话、WEB、邮件等方式来提供5*8小时的技术服务与支持;

服务期限:12个月。

服务内容::解决运行中出现的问题、提供解决方案、安装,数据库环境搭建、性能调优、协助应用程序迁移等。

 反映速度快,能够及时解决问题,服务与技术支持有保障.

如用户有特殊需要,还可提供现场技术支持,费用另计!

三、社区版与商业版的区别:

1、 社区版:

可以自由从网上下载,不提供没有任何技术支持服务。而且源码无规律, 出现问题后不容易查找。相当于一个大众测试版本。许多新的未经严格测试的特性都会很快加到社区版中让大家下载测试,类似于“试验田”,可靠性、稳定性不高。

 2、商业版 :

    软件经过严格认证,更加稳定、安全,性能比社区版好;平台优化,支持产权保护;包含企业级软件、服务和支持;出现问题后根据源码编排规律能够及时查找。

 

三、关于MYSQL的licenses使用问题:

1、商业用户购买的licenses后,在12个月的有效期内可以免费升级.超出有效期需要升级服务的,则需要另行购买产品,.(购买产品比购买服务便宜).

2、如果不需要进行安全更新服务升级的话,原有的licenses一直有效,可以继续使用。

***********************************************************

             MYSQL AB中国研发中心

        拓林思(中国)软件有限公司(turboliunx.inc.)

            北京万里开源有限公司       (greatlinux.inc)

                 

             宋桂平   MYSQL行业销售经理

            

地址:北京市朝阳区建国门外大街甲12号新华保险大厦5层503室

手机:13911253265

电话:010-65054020-315

传真:010-65054017

邮编:100022

邮件:michael.song@turbolinux.com.cn

网址:www.turbolinux.com.cn;

**************************************************************

 ua 回复于:2006-08-22 14:09:58

是不是我用ava访问mysql,没有买mysql的授权,java的源代码也要开源?似乎有点不合理吧!

 michael75 回复于:2006-08-22 14:21:16

是的,这就是GPL协议的精髓所在.

你必须要公开,除非你有MYSQL的授权.

 ua 回复于:2006-08-22 15:14:14

:em16:

 ua 回复于:2006-08-22 15:20:12

看来要学习postgresql了,据说那个是bsd协议,没有那么严格

 hobowang 回复于:2006-09-18 15:16:39

请问如果是用JSP,PHP之类的程序开发的WEB程序,用于自己运作,需要付钱吗

 michael75 回复于:2006-09-18 15:47:51

呵呵,只要你不卖给客户,不向客户收钱,可以用免费的.

 mynix 回复于:2006-10-03 11:01:48

“三、社区版与商业版的区别:

1、        社区版:

可以自由从网上下载,不提供没有任何技术支持服务。而且源码无规律, 出现问题后不容易查找。相当于一个大众测试版本。许多新的未经严格测试的特性都会很快加到社区版中让大家下载测试,类似于“试验田”,可靠性、稳定性不高。

2、商业版 :

    软件经过严格认证,更加稳定、安全,性能比社区版好;平台优化,支持产权保护;包含企业级软件、服务和支持;出现问题后根据源码编排规律能够及时查找。



问题:我们能从网上方便得到的是社区版,大多数lamp网站用的也是这个版本吧,稳定吗?可靠吗?本站也是用的这个版本吧?应该没问题吧?这在实际应用中应该是个问题吧。还有没有人关注这个问题?

 lsstarboy 回复于:2006-10-24 21:12:02

唉!没办法!

连PHP都不集成了,那Mysql还有什么吸引人的地方呢?

商业应用还要收钱,那么和其它的商业数据库还有什么区别呢,Mysql有什么优势和甲骨文比?商业应用会用Mysql?还搞什么商业版和社区版!严重的岐视穷人!

难道说要一个人只能在学习时用Mysql,商业应用要用别的数据库?

原来学习Mysql,只为它是开源的,想不到竟然有这样的协议!真让人伤心。

决定明天开始扔掉mysql,改postsql。由此,我也看到Mysql的灰暗的未来。

 lsstarboy 回复于:2006-10-24 21:22:20

顺便说一句,我个人理解,GPL并没有要求使用开源软件的软件开源。

举个例子:在linux中,ping这个工具是开源的,也许有个软件,还是商业软件,用到了这个工具的结果,比如说是测试一个主机是不是在线。那么这个软件也是违反GPL的吗?

同样的问题,为什么我们只是用mysql,而mysql强制我们必须开源?

还有,zend是借助于PHP的,而zend也没有开源!

最好的理由,如果要求使用开源软件的软件也开源,那么在linux之下,就不应该有商业软件!因为linux本身就是在GPL下的开源软件!

所以,我感觉,Mysql没有按照GPL规定去做,而是强加了一些“霸王条款”,强烈鄙视这种行为。

 jiazhengw 回复于:2006-10-24 22:30:46

呀,我不想学mysql了,我原来还以为是真正开源的呢!

 ashchen 回复于:2006-10-24 22:56:20

引用:原帖由 michael75 于 2006-8-22 14:21 发表

是的,这就是GPL协议的精髓所在.

你必须要公开,除非你有MYSQL的授权.

精髓?别吓唬人了

修改基于GPL源码而成的软件对外分发受GPL控制,如果只是调用一下MYSQL的数据库功能,付什么费?

GPL拉的屎是否还受GPL控制?

 ashchen 回复于:2006-10-25 00:05:24

支持MySQL的发展无可厚非,对于有一定经济实力的个人或企业也应该那么做,但是如果通过恐吓来到达目的就为人所不耻,那和敲诈勒索有什么区别?

这篇访谈可以增加对GPL协议的理解

http://www.zdnet.com.cn/developer/code/story/0,3800066897,39376955,00.htm

问:企业需要开放哪些源代码?

答:它们使用的GPL 代码以及衍生产品,没有使用GPL 源代码的部分则无须开放。

问:是什么使你有权追究违反GPL 的企业?

答:它们使用了Linux 内核,而我拥有部分Linux 内核的版权。在起诉时,我是作为个人版权所有者起诉的。

问:你认为GPL 与其它许可协议相比有什么不同之处?

答:这是一个哲学问题。BSD 许可协议允许使用源代码,并进行修改,而无需反馈给开发人员社区,但GPL 则要求将自己的修改反馈回社区。这是二种不同的软件开发哲学,选择哪种许可协议与具体的项目有关。例如,如果开发了一个新标准,并希望它迅速地普及,那么最好的方法是使用BSD 而不是 GPL

如果你通过修改基于mysql社区版的源码来增强或优化某些功能,并且发布了,你就有义务而且必须向mysql开发社区公布你修改了什么,不能把这种修改占为自己所有,否则拥有mysql版权的人有权力起诉你

开发者开发的java或者php程序,本身只是调用mysql的api,而mysql的api是GPL协议下的,如果你没有修改这些api源码而重新发布,mysql有什么权力要求公开java或者php的源码呢?

国内开发者大多没有直接修改mysql源码的能力和习惯,而只是使用基于mysql官方源码生成的可执行码

对于可执行码GPL的规定是第三条:

3.你可以以目标码或可执行形式复制或发布程序(或符合第2款的基于程序的作品),只要你遵守前面的第 l,2款,并同时满足下列3条中的1条。

  a)在通常用作软件交换的媒体上,和目标码一起附有机器可读的完整的源码。这些源码的发布应符合上面第1,2款的要求。或者

  b)在通常用作软件交换的媒体上,和目标码一起,附有给第三方提供相应的机器可读的源码的书面报价。有效期不少于3年,费用不超过实际完成源程序发布的实际成本。源码的发布应符合上面的第1,2款的要求。或者

  c)和目标码一起,附有你收到的发布源码的报价信息。(这一条款只适用于非商业性发布,而且你只收到程序的目标码或可执行代码和按 b)款要求提供的报价)。

GPL协议的目的是当你接收下载了一份GPL软件,你有获取,修改和查看源代码的权力,前提是你要把这种权力告诉你修改后软件的接受者使他们也拥有和你一样的权力,如果你不履行后者,将违反协议

[ 本帖最后由 ashchen 于 2006-10-25 11:01 编辑 ]

 UIRL 回复于:2006-10-25 09:00:31

支持ashchen

 lsstarboy 回复于:2006-10-25 14:25:20

支持ashchen的发言,这才是我的理解的GPL。

GPL只限制了修改,并没有限制使用。

 ashchen 回复于:2006-10-25 16:54:49

目前大家用到的软件可以大概分2种,商业软件和开源软件(遵循GPL,apache,BSD等协议的软件)

开发商业软件的公司只给用户使用权,并以此收费,其他权力保留,原因是开发公司投入了人力财力要收回成本并获利

开源软件大多是社区程序员无私的风险,其中GPL协议的软件保留版权,用户有查看原码和修改的权力;由于是社区开发,并没有明确的受益人,所以这类软件大多不向使用者收取费用,只要你有回报社区的想法或心存感激即可,也有软件作者希望使用者给与一定的资助或仅给他发一封感谢信,具体要看授权使用协议;从GPL文本可以看出GPL的对象是开发者或有开发能力的公司,对于那些想通过修改GPL原码发布并获利的人或公司是允许的,前提是要遵循GPL:即向接受者公开原码并告诉他们:“你有修改这些代码的权力,前提是要...”这是一个递归!

国内有的公司修改GPL软件后占为己有或不公开他的修改或者删除GPL协议也不告知他的客户拥有的权力,这是一种违反法律的行文,如果你想违反GPL协议可以向此软件版权所有者申请其他的许可协议

计算机软件和文字作品一样,通过人的智慧把一些元素组合起来能完成一定功能或表达思想,所有者拥有它的版权 所有权等一切权力,当然还能申请专利,拥有专利权,而一般用户需要得到的权力是使用权或得到服务,高级用户希望得到查看源码或修改的权力。软件所有者通过协议的方式授予用户一定的权力,如果你同意这份协议就达成了共识,这就是合同,各国对合同一般都有相关法律条文

以上为本人对协议的理解,若有不同意见请批评指正。系ashchen原创,查看不收费,引用请保留作者名,引用者无需公开身份住址信仰,银行帐号密码等信息,呵呵

[ 本帖最后由 ashchen 于 2006-10-25 21:17 编辑 ]

 ashchen 回复于:2006-10-25 20:48:02

看了一下MySQL.com商业许可和法律文本,MySQL是双许可协议的,并不只是GPL。

http://www.mysql.com/company/legal/licensing/commercial-license.html

The Commercial License is an agreement with MySQL AB for organizations that do not want to release their application source code. Commercially licensed customers get a commercially supported product with assurances from MySQL. Commercially licensed users are also free from the requirement of making their own application open source.

When your application is not licensed under either the GPL-compatible Free Software License as defined by the Free Software Foundation or approved by OSI, and you intend to or you may distribute MySQL software, you must first obtain a commercial license to the MySQL product.

Typical examples of MySQL distribution include:

Selling software that includes MySQL to customers who install the software on their own machines.

Selling software that requires customers to install MySQL themselves on their own machines.

Building a hardware system that includes MySQL and selling that hardware system to customers for installation at their own locations.

Specifically:

If you include the MySQL server with an application that is not licensed under the GPL or GPL-compatible license, you need a commercial license for the MySQL server.

If you develop and distribute a commercial application and as part of utilizing your application, the end-user must download a copy of MySQL; for each derivative work, you (or, in some cases, your end-user) need a commercial license for the MySQL server and/or MySQL client libraries.

If you include one or more of the MySQL drivers in your non-GPL application (so that your application can run with MySQL), you need a commercial license for the driver(s) in question. The MySQL drivers currently include an ODBC driver, a JDBC driver and the C language library.

GPL users have no direct legal relationship with MySQL AB. The commercial license, on the other hand, is MySQL AB's private license, and provides a direct legal relationship with MySQL AB.

With a commercial non-GPL MySQL server license, one license is required per database server (single installed MySQL binary). There are no restrictions on the number of connections, number of CPUs, memory or disks to that one MySQL database server. The MaxDB server is licensed per CPU or named user.

这份商业许可引发不少争议,大体就是你出售的非GPL软件如果用到MySQL,就需要购买MySQL商业许可。

[ 本帖最后由 ashchen 于 2006-10-25 20:50 编辑 ]

原文链接:http://bbs.chinaunix.net/viewthread.php?tid=814671

转载请注明作者名及原文出处

×××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××

                                                            转帖完毕

这几天关于其他一些孩子的新闻让人沉重

这两天听到下面3个关于孩子的新闻:

1、昨天,一个7岁智障女童走失。今天在下班路过一面墙看到上面的寻人启示。我自己用手机记下了上面的联系电话,万一我碰到了那个孩子可以跟她的家人联系呢。

2、一个读小学一、二年级的男孩被人贩子拐走。听人讲可能是人用吃的东西骗走的;现在各个幼儿园、小学上学放学时家长接送的人数骤增。

今天回到家再次教育孩子碰到陌生人不能跟着走,不能走给的东西,要大声呼喊。以前也记录过本地类似的事件,见:真是无奈,这么小的孩子就必须教她怎么防避坏人

3、一个高一的男生同人打架把人杀死了。听说这个孩子家挺有钱。平时奍成了小霸王脾气。现在的有不少孩子很任性,脾气大,以自我为中心。我发觉我们自己的孩子才3岁半,在家里脾气也很大。(见:孩子急躁时怎么办?孩子有时不听话是想得到大人的呵护和关怀吧对孩子的任性也宽容点吧?对待孩子的错误行为有时应该可以适当使用体罚孩子的脾气太坏了;孩子还算勇敢,等等)可在外面还算乖巧,甚至显得有点怯弱(见:孩子受其他小朋友欺负怎么办?)。尽管如此,我已经在考虑怎样把我们这棵小树苗押一押了,不能让她东倒西歪的生长。成人是成才的前提。

添加游客评论功能设计之测试计划

今天,添加游客评论功能设计所计划的功能已经基本实现。

1、实现过程中的改动:

  GuestArtInfo.java用原有的ArticleInfo.java代替;CookieManager.java因为所需要的代码少,另开一个类反而麻烦,功能直接写在了Action中;在util包中添加了一个处理解析存储在帖子正文头部的游客信息的工具类:GuestArtProcessor.java

2、一点心得:

  原来以为struts-config.xml中的“input="/disGoalContentAction.do"”只能用jsp文件,结果证明用*.do的路径也行,而且有时还必须如此。如下面:


        <action

            attribute="guestArtForm"

            input="/disGoalContentAction.do"

            name="guestArtForm"

            path="/postGuestArtAction"

            scope="request"

            type="com.learndiary.website.action.disgoal.PostGuestArtAction">

           

            <!--forward name="goalSuccess" path="/processGoalAction.do" /-->

           

            <!-- forward name="diarySuccess" path="/disall/disgoal/afterPostDiarySelect.jsp" /-->

            <forward name="goalSuccess" path="/toSendMailOfGoalAction.do" />

            <forward name="diarySuccess" path="/toSendMailOfGoalAction.do" />

            <forward name="isBackSubmit" path="/processGoalAction.do" />

            <forward name="isBackSubmit1" path="/disGoalContentAction.do" />

            <forward name="isBackSubmitGoal" path="/processGoalAction.do" />

            <forward name="adviceSuccess" path="/disGoalContentAction.do" />

            <forward name="adviceOfDiarySuccess" path="/disGoalContentAction.do" />

            <forward name="adviceOfGoalSuccess" path="/toSendMailOfGoalAction.do" />

            <forward name="messageSuccess" path="/main.do" />

            <forward name="failure" path="/disall/disgoal/disGoalContent.jsp" />

            <forward name="nonUser" path="/main.do" />

            <forward name="noParentArt" path="/main.do" />

        </action>

自己感觉有必要写个测试列表,进行逐项测试:

1,每项功能经过游客、注册用户、管理员的测试;每项功能在日记的评论和目标的评论中都要经过测试;

2,理想状态功能使用:

填写所有字段,无无效字符串。

3,用户信息为空,或只填用户名、邮件、网址其中一项或多项;

4,帖子内容或标题为空;

5,填写了字段,但是格式错误;

6,测试在其它页面游客发的帖子是否显示正常;

7,测试有游客发帖时的邮件发送内容是否正常;

8,测试有游客发帖时的RSS订阅内容是否正常。

9,传到网上公开测试;

例外:

1,因为软件暂时没有想到解决办法或麻烦,下列项暂时搁置:

1),网址格式过滤;

2),重复提交问题;

添加游客评论功能设计

本来,这个站根本没有朋友来回复(见:停止guest公共帐号,启用公共测试帐号),我又怕麻烦,又想学点东西,近段时间就不打算写网站的程序了。但是,我想,万一有某个朋友有心发表点意见,一看还要注册、登录,结果想在这里留点我认为弥足珍贵的文字也打退堂鼓了。基于“不怕一万,就怕万一”的理论,万一有朋友来访,我们不能拒朋友于门外吧。

1、基本功能:

就是一般博客站的游客回复功能(如http://www.jiehoo.comhttp://www.chinamyhosting.com等),具体为:

1),回复表单在显示帖子内容的下方;

2),字段包括:

名字(必须),邮件(必须),网站(可选),标题(必须,系统自动给出re:....的标题,可以修改),内容(必须);

3),朋友在提交评论后,写入cookie,以后再次访问时不用输入除标题和内容的字段;

2,以上功能在本站实现的要点:

1),回复表单在显示帖子内容的下方:

可以参考上传文件使用的frame结构,为了简化实现,游客回复去掉上传文件功能,但可以使用UBB语法;

2),因为本站已有的数据结构和为了简化实现,所有游客的回复在系统中划为一个游客帐号的帖子;但是,为了显示上述字段,可以把上面的“名字(必须),邮件(必须),网站(可选)”字段加在内容前面,并加入特殊的分隔符,把上述字段连同内容存入数据库;要显示游客的回复的时候,把从数据库中取出的内容字段分离出“名字(必须),邮件(必须),网站(可选)”字段用于显示相关内容。

这样,在取出一篇日记或目标的评论列表,并把它们显示出来的时候,对划归游客帐号的帖子的显示格式有所变化;

3),游客发表的帖子不能被普通用户修改,但管理员可以修改和删除(例如有可能出现的垃圾信息)。

4),因为游客帐号需要保存的cookie信息没有密码,也用不着把游客的相关历史信息存入数据库。

3,具体实现:

1),jsp页面文件:只有一个显示日记或目标内容的页面需要在下部加一个游客留言的frame;

2),java文件:传递游客信息需要增加一个GuestArtInfo.java,一个相应的FormBean:GuestArtForm.java,一个提交游客评论的Action:PostGuestArtAction.java,一个游客每次提交评论成功后的cookie写入方法,可以把这个方法归入到util包,为了高效,单独建一个类CookieManager.java,方法的名字就是writeCookie(Ojbect cookieInfo),然后,在用户以后来访问的时候,有一个读取cookie信息的方法:Object readCookie()也放在CookieManager中,同样。在这里,读了cookie还有一个传入游客评论frame页面的过程,这时,又需要建立一个保持cookie信息的GuestInfo.java

3),为了把游客的评论归入系统的单独一个游客帐户统一管理和简化实现,关健是要把“名字(必须),邮件(必须),网站(可选)”字段以特殊的标记加在内容前面,要显示时再把这些字段分离出来(日记的作者和管理员可以看见这些特殊内容),而且这个过程对用户来说是透明的。

初步设想如下:

存入数据库格式:


[guest]

 [name]

   littlebat

 [/name]

 [gemail]

   mdx-xx@tom.com

 [/gemail]

 [site]

   http://java.learndiary.com

 [/site]

[/quest]

评论内容

分离数据方式:

用正则表达式分离[guest]和[/guest]之间的内容,再用正则表达式把各个字段分离出来封装进上面保持游客cookie信息的GuestInfo.java类中。这个类的对象传入显示页面再读出来进行显示。

游客评论的显示格式为:标题  <a href=游客网站>游客名字</a> 发表时间

4、实现步骤:

1),依次完成GuestArtInfo.java,GuestInfo.java,CookieManager.java,GuestArtForm.java,PostGuestArtAction.java

2),完成jsp页面

3),测试和发布

5、时间:

想做就做,做完为止。

用"堆栈区数据复制"理解Java赋值和参数传递机制的心得

提纲:

1、版权声明

2、前言

3、正文

4、结论

5、附注

6、参考资料

===========================================================================================================================

1、版权声明:

  本文作者:littlebat,原始出处:用"堆栈区数据复制"理解Java赋值和参数传递机制的心得 (http://java.learndiary.com/disDiaryContentAction.do?goalID=2716),邮件:mdx-xx@tom.com。如有任何反馈意见请联系作者,作者会在本文原始出处随时更新此文。转载及引用请保留此版权声明,谢谢。

2、前言:

  在所有一切之前,先让我们看一个例子,如果您能得出这个例子的正确答案,下面的内容您应该基本上领会了。当然,请注意,本文不光只是阐述Java方法的参数传递问题,站在一个统一的角度还包括Java的赋值操作。如果您有兴趣,不妨把它看完:)

  例子1源码:Tester.java(摘改自:Java参数传递方式)


public class Tester {

    public static void main(String[] args) {

        int primitive = 2;

        changePrimitive(primitive);

        System.out.println("Step 1, primitive = " + primitive); //Step 1

        //问题1:请问,Step 1这里primitive的值是多少?

        MyClass myClass = new MyClass(); // Step 2

        System.out.println("Step 3, myClass = " + myClass); //Step 3

        changeObject(myClass);

        System.out.println("Step 8, myClass = " + myClass); //Step 8

        System.out.println("Step 9, myClass.i = " + myClass.i); //Step 9

        //问题2:请问,Step 8这里myClass指向的是执行方法changeObject(MyClass)之前的Step 3的那个对象,

        //还是在方法changeObject(MyClass)中的Step 5新生成的那个对象?

        //问题3:现在,Step 9中,myClass.i等于多少了?

    }

    public static void changePrimitive(int primitive) {

        primitive = 3;

    }

    public static void changeObject(MyClass myClass) {

        System.out.println("Step 4, myClass = " + myClass); //Step 4

        myClass.i = 3;

        myClass = new MyClass(); //Step 5

        System.out.println("Step 6, myClass = " + myClass); //Step 6

        System.out.println("Step 7, myClass.i = " + myClass.i); //Step 7

    }

}

class MyClass {

    int i = 0;

}

请认真想好,例子中3个问题您的答案是什么?

这里是标准答案:

问题1:primitive = 2

问题2:myClass仍然指向的是执行方法changeObject(MyClass)之前的Step 2的那个对象。

问题3:myClass.i = 3

您做对了吗(首先坦白,在写这篇文章之前,我得出了错误的答案:(,见:Java参数传递方式(转帖))?怎么,像我一样,没做对?那么您该好好读一下下面的内容了,读了之后还做不对的话就把我这篇帖子扔进垃圾堆吧。不过,扔之前能给我回复一下为什么我将感激不尽:)

3、正文:

  关于Java的赋值和参数传递是按值(by value)进行的还是按引用(by reference)进行的,这个问题曾经迷惑了很多人,包括我。而且,我想,这个问题还将继续迷惑一些人,包括那些C++的高手。

  在这里,我不准备用“按值(by value)”和“按引用(by value)”这样的术语来阐述这个问题。因为,从字面的理解来看,这样的术语在不同的人头脑里有不同的含义。我试图从Java数据(包括原始类型(primitive type)和对象(ojbect))在内存中的存储这个角度,用一个自创的“术语”来阐述我对这个问题的理解。这个术语就是:“堆栈区数据复制(Stack Data Copy,简称SDC)”。详细一点就是:在Java中,不管是赋值操作还是参数传递操作--针对原始类型(primitive type),是对堆栈区的原始类型的值进行复制;针对对象,是对储存在堆栈区的,对象的引用中所储存的_对象的值被存储的地址_进行复制。

  像上面抠字眼的句子读起来比较费力,我在后面将用两个例子并结合一些示意图来阐述我对这个问题的理解。希望各位朋友帮助纠正错误。

1)、赋值操作:

例子2源码:(Assign.java)


public class Assign{

  public static void main(String[] args){

    int i = 1;

    Object o = new Object();

    System.out.println("i = " + i + " ; o = " + o ); // Step 1 (示意图:3-1-1)

    int j = i;  

    Object p = o;

    System.out.println("i = " + i + " ; j = " + j + " ; o = " + o + " ; p = " + p); //Step 2 (示意图:3-1-2)

    j++;

    p = new Object();

    System.out.println("i = " + i + " ; j = " + j + " ; o = " + o + " ; p = " + p); //Step 3 (示意图:3-1-3)

  }

}

对上面例子的说明:

(1),Step 1中,整数i和对象o得到赋值。

示意图3-1-1

从示意图3-1-1中可以看出:整数i存储在堆栈区(Stack);对象o的引用存储在了堆栈区,但是对象o的值却存储在了内存堆中(Heap),对象o的引用存储了对象o的地址。

Step 1在我的机器上的一次输出结果:


i = 1 ; o = java.lang.Object@a90653

至于对象o的值输出来怎么会是那个样子,我只能告诉您:在java程序的一次运行过程中,每个Object对象输出这样的值是唯一的,因此可以借此来判断对象的引用指向的对象是否发生了改变。详情请参考Java API 文档(下同,这里给出的是:J2SE 1.5.0 API 中文版):

http://gceclub.sun.com.cn/Java_Docs/html/zh_CN/api/java/io/PrintStream.html#println(java.lang.Object)

http://gceclub.sun.com.cn/Java_Docs/html/zh_CN/api/java/lang/Object.html#toString()

(2),Step 2中,把整数i赋值给了整数j,把对象o赋值给了对象p。

示意图3-1-2

从示意图3-1-2中可以看出:整数i的值复制给了整数j,整数j同样存储在堆栈区;存储在堆栈区的对象o的引用中存储的_对象o的值的地址C_复制给了对象p的引用,对象p的引用同样在堆栈区中。因为对象p的引用_得到了对象o的引用复制过来的_对象o的值的存储地址C,所以对象p的引用_和对象o的引用_都指向了在堆(heap)中的同一个对象,并且,这个对象的地址是地址C。

Step 2在我的机器上的一次输出结果:


i = 1 ; j = 1 ; o = java.lang.Object@a90653 ; p = java.lang.Object@a90653

(3),Step 3中,整数j的值加1,赋给了对象p新的对象值。

示意图3-1-3

从示意图3-1-3中可以看出:整数i的值不变,整数j的值加1变为2,整数在堆栈区中;新生成的对象的值存储在了堆(Heap)中,地址为F。新生成对象的值的地址F_存储在了堆栈区p的引用中,替换了原来存储在其中的地址C。于是,p的引用就指向了新生成的对象,这个新生成的对象的值的地址_是地址F。而整数i和对象o的(包括对象o的引用)没有改变也不曾有任何改变(除了初次赋值)。

Step 3在我的机器上的一次输出结果:


i = 1 ; j = 2 ; o = java.lang.Object@a90653 ; p = java.lang.Object@de6ced

至此,通过上面的例子及其示意图和说明,我得到一个结论:

在Java赋值操作中,针对原始类型(primitive type),是对堆栈区的原始类型的值进行复制;针对对象,是对储存在堆栈区的,对象的引用中所储存的_对象的值被存储的地址进行复制。这就是术语:“堆栈区数据复制(Stack Data Copy,简称SDC)”在Java赋值操作中的阐述。

2)、方法中的参数传递操作:

例子2源码:(PassParameter.java)


public class PassParameter{

  static void showMe(int pi, Object po){

    System.out.println("pi = " + pi + " ; po = " + po); // Step 2 (示意图:3-2-2)

    pi++;

    po = new Object();

    System.out.println("pi = " + pi + " ; po = " + po); // Step 3 (示意图:3-2-3)

  }

  public static void main(String[] args){

    int i = 1;

    Object o = new Object();

    System.out.println("i = " + i + " ; o = " + o); // Step 1 (示意图:3-1-1)

    showMe(i, o);

    System.out.println("i = " + i + " ; o = " + o); // Step 4 (示意图:3-2-3)

  }

}

对上面例子的说明:

(1),Step 1中,与上面Assign.java中的Step 1相同,略,下面重复其示意图3-1-1。

示意图3-1-1

Step 1在我的机器上的一次输出结果:


i = 1 ; o = java.lang.Object@a90653

(2),Step 2中,与上面Assign.java中的Step 2类似,只是Assign.java中的整数j和对象p变成了这里的方法showMe()中的参数:整数pi和对象po。并且,由于这里是参数传递,把Assign.java示意图3-1-2中的“=”替换成PassParameter.java示意图3-2-2中的“<--”,以此表示是参数传递。据我的理解,它们是一回事。

示意图3-2-2

Step 2在我的机器上的一次输出结果:


pi = 1 ; po = java.lang.Object@a90653

(3),Step 3和Step 4合并起来,见示意图3-2-3同样,与上面Assign.java中的Step 3类似。

示意图3-2-3

Step 3和Step 4在我的机器上的一次输出结果:


pi = 2 ; po = java.lang.Object@de6ced

i = 1 ; o = java.lang.Object@a90653

至此,通过上面的例子及其示意图和说明,我得到一个结论:

在Java方法参数传递操作中,针对原始类型(primitive type),是对堆栈区的原始类型的值进行复制;针对对象,是对储存在堆栈区的,对象的引用中所储存的_对象的值被存储的地址进行复制。这就是术语:“堆栈区数据复制(Stack Data Copy,简称SDC)”在Java方法参数传递操作中的阐述。

4,结论

综上所述:在Java中,不管是赋值操作还是方法的参数传递操作--针对原始类型(primitive type),是对堆栈区的原始类型的值进行复制;针对对象,是对储存在堆栈区的,对象的引用中所储存的_对象的值被存储的地址进行复制。

所以,据我的理解,术语:“堆栈区数据复制(Stack Data Copy,简称SDC)”能够有助于理解在Java中进行赋值和传递参数的机制,能够有助于在一定程度上消除“传值”、“传引用”等语义上的多变性的负面影响,可以提出来供大家交流。

5,附注:

由于本人水平有限,上面的一切全是基于实践进行的带有一些推测成分在内的个人心得总结。我也以上面的自创术语去成功解释过一些文章中的有关问题(如下面参考资料中的例程)。谨希望在能为部分Java初学者提供一个理解Java赋值和参数传递的手段的同时,更能得到各位朋友的斧正,以便能够对这个问题形成更加正确和准确的认识。在我提高认识的同时,我会在本文原始出处:用"堆栈区数据复制"理解Java赋值和参数传递机制的心得 (http://java.learndiary.com/disDiaryContentAction.do?goalID=2716)中随时更新此文。再次贴出我的邮件:mdx-xx@tom.com。谢谢。

6,参考资料:

1),Java参数传递方式 (http://www.jiehoo.com/java-pass-parameter.htm)

2),破除java神话之二:参数是传址的 (http://www.javaresearch.org/article/showarticle.jsp?column=544&thread=443)

3),Java 应用程序中的按值传递语义 (http://www.javaresearch.org/article/showarticle.jsp?column=1&thread=706)

4),我对《Java 应用程序中的按值传递语义》的理解 (http://www.javaresearch.org/article/showarticle.jsp?column=1&thread=3156)

5),Thinking in Java, 3rd Edition in Java (http://www.mindviewinc.com/downloads/TIJ-3rd-edition4.0.zip)

                                                              全文完

                                                              2006年11月22日午首稿

                                                              2006年11月24日下午第一次更新

                                                              2006年11月28日早晨第二次更新(局部小更新)

Thinking in Patterns chapter 10: Connecting different types

Thinking in Patterns with Java V0.9: chapter 10: Connecting different types: TIPatterns.htm#_Toc41169731

1, The sections name of today's learning;

Adapter. 84

Bridge. 87

Exercises. 93

2, What is it talk about in these sections and my comments and feeling for the content:

Maybe, I have gotten most feeling in this chapter. After some reading and thinking, I think I have understood these two patterns. In addition, through this chapter, I have known a little more about Proxy pattern.

1), Adapter

From my feeling, Adapter can be seen as a generlization of Proxy, and Proxy is a specific of Adapter. My understanding is below:(UML diagram is at the end of this diary)

1>, From the example: adapter:SimpleAdapter.java for Adapter and the example: proxy:ProxyDemo.java for Proxy, we can see little difference between them;

2>, From the example: adapter:AdapterVariations.java for Adapter, I haven't seen a little piece of Proxy.

Then, let us see their effects:

Proxy: fronting for another object

Adapter: Connecting different types

So, I can say in Proxy pattern: the proxy object and the implementation object these two types objects are connected by the Proxy pattern;

And, Adapter has more usage, it can unite different objects to achieve a job.

Review Bruce's words about proxy(in the end of section: Proxy: fronting for another object in chapter: Object decoupling): Of course, it isn’t necessary that Implementation have the same interface as Proxy; as long as Proxy is somehow “speaking for” the class that it is referring method calls to then the basic idea is satisfied (note that this statement is at odds with the definition for Proxy in GoF).

Then look at this statement at the end of this section: I’m taking liberties with the term “proxy” here, because in Design Patterns they assert that a proxy must have an identical interface with the object that it is a surrogate for. 

Maybe, I have found the reason of GoF's "assert that a proxy must have an identical interface with the object that it is a surrogate for. ", only in this way, Proxy pattern can be a standalone pattern in 23 patterns, otherwise, maybe it can be mixed into adaper, then, there are only 22 patterns exist now:)

And, maybe, Proxy has been used long time by people, we can't ignore its existence, it must be a standalone pattern. And, its work focuses on "fronting for other".

I can't express my entire feeling with my poor english, maybe, writing my diary in english is an error?

2), Bridge:

The most feeling in this chapter is: don't think that authority's words is all right, including GoF's. Bruce got a result after listening some other's idea about Bridge pattern, this result is: GoF's Design Patterns did "a miserable job of describing Bridge", and, there is only one place in GoF's Design Patterns is a lightspot-Bruce says continuely:"except in one place not the general structure chart describing the pattern, which wasn't helpful, but in the structure chart describing their specific example. Only if you stare at that for a bit does Bridge begin to make sense.". From this only lightspot, Bruce put up with a example of his Bridge pattern (and, maybe, is also GoF's), and, at least, I know the Bridge pattern is "often a construct that is used to help you write code. ", and it's goal is "to allow you to structure your code so that you can easily add new kinds of front-end objects which are implemented with functionality in new kinds of back-end objects."

An another meaningful statement for me is "But keep in mind that the vector of change with Bridge is typically happening at coding time: it keeps your code organized when you are dealing with an increasing number of options for implementing functionality."

Bridge pattern is a bridge between "front-end objects" and "back-end objects", regardless the number and the type of all these objects, it can provide an interface at front-end, receive all other front-end objects' requests and hand these requests to back-end interface, and it provides an interface at back-end, receive the requests which come from the front-end interface and hand these requests to back-end objects to fulfill the requests.  

3, My questions about the program itself;

1), the real application of these two patterns;

2), exercises;

4, My questions about the english language;

1), Strange words:

adaptee, take liberty with, unenlightened, begin by, conference, perspectives, give (a) talk, armed with, misinformation, delve, miserable, construct, in common, delegate, combinatorial, bookkeeping, clerking, associative, radically, Effectively

===============================================================================

//: proxy:ProxyDemo.java

// Simple demonstration of the Proxy pattern.

********************************************************************

//: adapter:SimpleAdapter.java

// "Object Adapter" from GoF diagram

********************************************************************

//: adapter:AdapterVariations.java

// Variations on the Adapter pattern.

********************************************************************

//: bridge:BridgeStructure.java

// A demonstration of the structure and operation

// of the Bridge Pattern.

********************************************************************

demonstrate the structure of Bridge

=================================================================================

                          incomplete

Java参数传递方式(转帖)

转自:http://www.jiehoo.com/java-pass-parameter.htm

Java参数传递方式

其实这个问题我原来翻译(破除java神话之二:参数是传址的 )、转帖别人的详细解释(Java 应用程序中的按值传递语义 )和专门解释( 我对《Java 应用程序中的按值传递语义》的理解)过,不过现在看来,原来翻译或者解释的角度是有问题的,从底层的角度解释并不直观,在交流的时候也容易引起误解,最终不能达成一致意见。下面以最终的效果来解释参数的传递方式:

1、对于原始数据类型,也就是int、 long、char之类的类型,是传值的,如果你在方法中修改了值,方法调用结束后,那个变量的值没用改变。

2、对于对象类型,也就是Object的子类,如果你在方法中修改了它的成员的值,那个修改是生效的,方法调用结束后,它的成员是新的值,但是如果你把它指向一个其它的对象,方法调用结束后,原来对它的引用并没用指向新的对象。

代码如下:

public class Tester {

    public static void main(String[] args) {

        int primitive = 2;

        changePrimitive(primitive);

        //primitive的值依然是2

        MyClass myClass = new MyClass();

        changeObject(myClass);

        //myClass仍然指向的是执行changeObject之前的那个对象

        //但是myClass.i等于3了

    }

    public static void changePrimitive(int primitive) {

        primitive = 3;

    }

    public static void changeObject(MyClass myClass) {

        myClass.i = 3;

        myClass = new MyClass();

    }

}

class MyClass {

    int i;

}

对于远程调用,无论是什么类型,调用结束后,传入的参数和以前没用任何变化(当然前途是直接调用远程方法,如果中间经过其它的Proxy类或者Facade类,不能保证那些类对对象没用修改)。至于是通过Locale接口进行调用的,我不太清楚是否属于远程调用。以后确定了再来更新。

作者: Cherami

原载: Java参数传递方式

版权所有。转载时必须以链接形式注明作者和原始出处及本声明。

相关日志

    * 修复不能评论的问题

    * 使用参数方式还是页面配置方式

    * 我使用的WordPress插件

    * 解析XML的时候完全忽略DTD

随机日志

    * 机场也可以种树

    * Response被关闭

    * Java面试中的经典对比问题

    * 在目录中查找类位于哪个jar包中

添加到网摘

[del.icio.us]  [新浪 VIVI]  [365key]  [YouNote]  [博采中心]  [Poco]  [SOHU狐摘]  [天极网摘]  [和讯网摘]

喜欢这个插件?

当前日志信息

标题:

    Java参数传递方式

发表:

    2006-11-15

分类:

    Java

标签:

    java, 参数传递, 传值, 传引用

点击:

    28

评价:

    Votes | Average: 0 out of 5 Votes | Average: 0 out of 5 Votes | Average: 0 out of 5 Votes | Average: 0 out of 5 Votes | Average: 0 out of 5 (暂无评价)

    Loading ... Loading ...

该日志共有 3 条评论

发表评论 | RSS订阅 | 反向链接

   1. oneal 2006-11-15

      local 调用相当于同一个虚拟机上的对普通对象方法的调用。

      上面那段代码眼熟啊,上个月做过,哈哈。

   2. Cherami 2006-11-16

      local调用可能是本地调用,但是感觉有可能会换成远程调用,这样如果没有意识到,可能会有潜在的bug。因为本地调用和远程调用的特性是不一样的。可能会误用特性。

   3. English Study and Sharing » 博客文章 » Java参数传递方式 2006-11-19

      […] 对于远程调用,无论是什么类型,调用结束后,传入的参数和以前没用任何变化(当然前途是直接调用远程方法,如果中间经过其它的Proxy类或者 Facade类,不能保证那些类对对象没用修改)。至于是通过Locale接口进行调用的,我不太清楚是否属于远程调用。以后确定了再来更新。 作者: Cherami 原载: Java参数传递方式 […]

Thinking in Patterns chapter 9: too many

Thinking in Patterns with Java V0.9: chapter 9: too many: TIPatterns.htm#_Toc41169721

1, The sections name of today's learning;

  Flyweight: too many objects. 66

  Decorator: too many classes. 69

    Basic decorator structure. 70

    A coffee example. 70

    Class for each combination. 70

    The decorator approach. 73

    Compromise. 78

    Other considerations. 82

    Exercises. 83

2, What is it talk about in these sections and my comments and feeling for the content;

  I have never felt the design pattern's importance so strong until I read this chapter, especially the section Decorator: too many chasses.

  1), Flyweight: too many objects. 66

  For my understanding, the key of Flyweight pattern is: put all the objects of a class into one object which I named it "all_in_one", get the any object of many object from this "all_in_one" object by passing the "index" of any object of many object into this "all_in_one".

  By running the modified example in this section, I am sure it's really true.

  I modified "size = 1000000" to "size = 5000000" in flyweight:ManyObjects.java, and ran it, it reported:


Exception in thread "main" java.lang.OutOfMemoryError: Java heap space

        at ManyObjects.main(ManyObjects.java:22)

The same "size = 5000000" in flyweight:FlyWeightObjects.java works well, and the running time is less much than the running time in flyweight:ManyObjects.java with "size = 1000000"( with a less size, it works.).

At the end of this section, Bruce warn us don't do a "premature optimization" by using flyweight pattern unless discovering performance bottlenecks of too many objects by using a profiler tool, I think if I haven't misunderstood his words.

2), Decorator: too many classes. 69

Just this pattern give me so strong of pattern's importance. And, the example of "coffee shop" posted by Bruce is so natural and proper. I can understand the meaning of this pattern by this example even the program detail isn't very clear for me.

For my understand, I put up another example for this pattern: "man", then decorate "man" with "good man", "wise man", "old man", "strong man", at last, a strong old wise good man appears.

Without the Decorator pattern, there will be many class need to be created in Bruce's coffee shop example.

With the Decorator pattern, there are two approachs, one is "pure" decorator, and another is compromise which mixes the approach of without decorator and with decorator.

In most real stiuations, a compromise way should be taken.

This is really a book which "Problem-Solving Techniques using Java".

The uml classes diagrams of these three approachs of solving too many classes problem which from this book is at the end of this diary.

3, My questions about the program itself;

1), "implicit this pointer in method calls, the “this index” is passed in as the first argument.", how does the implicit "this" pointer work step by step in JVM? 

4, My questions about the english language;

1), Strange words:

flyweight, odd, in the company of, hack, prohibitive, excessive, externalize, pretend, untenable, admonishment, guesswork, layered, refer to as, account for, go down to, espresso, latte, teas, whip, decaf, sizeable, Mocha, steamed, foam, conform to, mug, assembling, arduous, Compromise, present, get away, syrup, Follow the compromise approach to create a menu consisting of a Margherita, Hawaiian, Regina, and Vegetarian pizzas, with toppings (decorators) of Garlic, Olives, Spinach, Avocado, Feta and Pepperdews. Create a Hawaiian pizza, as well as a Margherita decorated with Spinach, Feta, Pepperdews and Olives. detaching, beverage

2), Strange sentences:

1>, Firstly, the combinations are fixed statically so that any combination a customer may wish to order needs to be created up front.

2>, However, the implications to the all decorator or compromise approaches are the same - one extra class is created.

=============================================================================

Basic decorator structure

******************************************************************

Class for each combination

******************************************************************

The decorator approach

******************************************************************

Compromise

不能对孩子开这样的玩笑!

昨天中午,我送孩子上幼儿园。到了幼儿园门口,她非要零食吃。孩子这段时间吃零食太多了。在家里才吃了零食,所以我不准备给她买。店主在里面,我没有自己喊。孩子自己喊了几声没反应。我就开玩笑地对她说:“你看,老板不在,买不成。你想吃,自己去拿吧,看拿不拿得到?”

她站在玻璃柜台前面,往里看了又看,看玻璃柜后面。很像跃跃欲试的感觉。我一看,马上意识到我已经无意中犯了一个错误,也许还不小。就自己喊了老板给孩子买了零食吃。

这样的玩笑不能够对孩子开。孩子就像一张白纸,是没有任何对错是非观念的。你叫她去柜台里直接拿吃的,也许在她的理解就是:大人都叫我拿,这肯定是可以拿的了。如果经常反复这样,对孩子的行为习惯的塑造极为不利。

我记得自己读小学1,2年级的时候,自己还算老实吧,跟一个很调皮的孩子一起玩。然后就很自然的一起从一个缝隙钻到大伯屋里偷偷拿了大伯的钓鱼杆,这事还引起了大人之间的误会。在我当时的印象中,根本就不知道这叫作“偷窃”。

所以,我想起,有些大人爱跟小孩子开玩笑,比如,叫孩子去拿别人的东西,去打别人,去骂别人(如不雅的外号),等等。结果,在大人的哈哈大笑中,可能就给小孩的行为习惯甚至道德的培养上留下了阴影。

所以,在孩子面前开玩笑,大人们还需要三思而后行!

Thinking in Patterns chapter 8: Specialized creation

Thinking in Patterns with Java V0.9: chapter 8: Specialized creation: TIPatterns.htm#_Toc41169717

1, The sections name of today's learning;

Prototype. 61

Builder. 62

Exercises. 66

2, What is it talk about in these sections my comments and feeling of the content:

1), Prototype

Come up with it at this chapter, but will descript it later.

2), Builder.

"They never define exactly what they mean by representation. ", "but alas, ", etc... Again, Bruce appears to be not satisfied with the GoF's work about this part. At the end of this section, Bruce gives a simple definition of "Builder" pattern is: "Thus, Builder could be described as using a Policy to create objects."

And, maybe I have known a difference between "State" and "Builder" is: State "simply forwarding the requests" , Builder "has a sequence of operations to perform", and both "State" and "Builder" is called by a context to perform its job. At this point, maybe I have seen a little meaning of the "context" which mentioned at the begin of this book as "it will often be the controller that manages the operation of the pattern". In the example: state:StateDemo.java, the context class is "ServiceProvider", in the example: builder:BuildMedia.java, the context is "MediaDirector".

And, maybe I have also known a little of statement appeared at the section of State pattern: "State can be found everywhere because it’s such a fundamental idea. For example, in Builder, the “Director” uses a backend Builder object to produce different behaviors.".

At this point, the difference of "State", "Strategy", "Policy", "Builder" patterns make me a bit dizzy. But, I think if I read more source code of these patterns and apply these patterns in some real projects (like LearnDiary), maybe I will master these patterns really, and maybe create my own design patterns, isn't it?

3, My questions about the program;

1), Although the resulting “object” (the entire converted text file) is created over time, if you consider the conversion of each RTF directive to be an object, this feels to me a little more like Bridge, because the specific types of converters extend the interface of the base class.

2), exercises;

4, My questions about the english language;

1), Strange words:

representation, spread out, over time, essence, maze, alas, overwhelmingly, compelling, a.k.a. (Also known as.), in some ways

2), Strange sentences:

1>, The final variation of the maze builder is something that doesn’t create mazes at all, but instead counts the rooms in an existing maze.

===============================================================================================================

UML classes diagrams of examples mentioned in this chapter:

**********************************************************************************************

//: state:StateDemo.java

// Simple demonstration of the State pattern.

 

*****************************************************************************************************

//: strategy:StrategyPattern.java

//Strategy: choosing the algorithm at run-time

***************************************************************************************************

//: builder:BuildMedia.java

// Example of the Builder pattern

                                                      incomplete