<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Some reminiscences, some memories &#187; NetBeans</title>
	<atom:link href="http://www.mikespook.com/index.php/category/java/netbeans/feed" rel="self" type="application/rss+xml" />
	<link>http://www.mikespook.com</link>
	<description>Just another boring day</description>
	<lastBuildDate>Wed, 28 Jul 2010 03:47:35 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<item>
		<title>Netbeans 6.8 发布，首先需要解决的小bug</title>
		<link>http://www.mikespook.com/index.php/archives/441</link>
		<comments>http://www.mikespook.com/index.php/archives/441#comments</comments>
		<pubDate>Fri, 11 Dec 2009 03:02:14 +0000</pubDate>
		<dc:creator>mikespook</dc:creator>
				<category><![CDATA[NetBeans]]></category>
		<category><![CDATA[bug]]></category>

		<guid isPermaLink="false">http://www.mikespook.com/?p=441</guid>
		<description><![CDATA[Oracle 对 Sun 的收购，还未真正尘埃落定，坊间就流言四起……Netbeans 6.8 的发布，无疑增强了大家对 Netbeans 在带着神谕的阳光下生存下去的信心。于是，还未上班前，趁着大家吃早餐的时间全速下回来了最新的 Netbeeans 6.8 的 j2se 开发版本。赏玩一番…… 本来呢，由于工作的原因，Netbeans 我会用来做 PHP、C 的开发（无奈 python 插件还有许多 bug，python 的开发已经迁移到 pyDev 了），java 本身只是做做作业，随便玩以下的。但是完整的 Netbeans 版本体积直逼 Eclipse，下载起来实在让人心焦，所以就按照以往的习惯，下一基本的版本，再安装插件。 新的启动闪屏还是很有感觉的，貌似，能提高编码的兴趣……我是瞎说的…… 菜单中文字体过小的这个缺陷看来还没有被修正。或许 Netbeans 的开发人员不觉得菜单字太小是个麻烦吧。 打开了“工具-&#62;插件-&#62;可用插件”准备安装 PHP、Python、C/C++ 的支持插件。这时发现不对了，插件怎么这么少？只有 21 个？看错了？Bug？搜索了以下，PHP 插件只有“Selenuim Module for PHP”这个 beta 版的插件。正式版的 PHP 插件没有了。Python 这个 Beta 版的插件有。C/C++ 支持这个正式的插件没有。 这实在太诡异了……是不是插件目录加载不完全？点击“重新装入目录”让 Netbeans 重新加载下插件目录，这时出问题了： 居然提示我无法连接……难道是给墙了？在浏览器里打开 Netbeans 默认的更新地址：http://dlc.sun.com.edgesuite.net/netbeans/updates/6.8/uc/final/stable/catalog_zh_CN.xml.gz，404 错误，原来是插件目录文件不存在。 [...]]]></description>
			<content:encoded><![CDATA[<p>Oracle 对 Sun 的收购，还未真正尘埃落定，坊间就流言四起……Netbeans 6.8 的发布，无疑增强了大家对 Netbeans 在带着神谕的阳光下生存下去的信心。于是，还未上班前，趁着大家吃早餐的时间全速下回来了最新的 Netbeeans 6.8 的 j2se 开发版本。赏玩一番……</p>
<p>本来呢，由于工作的原因，Netbeans 我会用来做 PHP、C 的开发（无奈 python 插件还有许多 bug，python 的开发已经迁移到 pyDev 了），java 本身只是做做作业，随便玩以下的。但是完整的 Netbeans 版本体积直逼 Eclipse，下载起来实在让人心焦，所以就按照以往的习惯，下一基本的版本，再安装插件。</p>
<p><a href="http://www.mikespook.com/wp-content/uploads/2009/12/netbeans-6.8-splash.png"><img class="alignnone size-full wp-image-442" title="netbeans-6.8-splash" src="http://www.mikespook.com/wp-content/uploads/2009/12/netbeans-6.8-splash.png" alt="netbeans-6.8-splash" width="472" height="297" /></a><span id="more-441"></span>新的启动闪屏还是很有感觉的，貌似，能提高编码的兴趣……我是瞎说的……</p>
<p>菜单中文字体过小的这个缺陷看来还没有被修正。或许 Netbeans 的开发人员不觉得菜单字太小是个麻烦吧。</p>
<p>打开了“工具-&gt;插件-&gt;可用插件”准备安装 PHP、Python、C/C++ 的支持插件。这时发现不对了，插件怎么这么少？只有 21 个？看错了？Bug？搜索了以下，PHP 插件只有“Selenuim Module for PHP”这个 beta 版的插件。正式版的 PHP 插件没有了。Python 这个 Beta 版的插件有。C/C++ 支持这个正式的插件没有。</p>
<p>这实在太诡异了……是不是插件目录加载不完全？点击“重新装入目录”让 Netbeans 重新加载下插件目录，这时出问题了：<a href="http://www.mikespook.com/wp-content/uploads/2009/12/netbeans-6.8-warning.png"><img class="alignnone size-full wp-image-443" title="netbeans-6.8-warning" src="http://www.mikespook.com/wp-content/uploads/2009/12/netbeans-6.8-warning.png" alt="netbeans-6.8-warning" width="422" height="370" /></a></p>
<p>居然提示我无法连接……难道是给墙了？在浏览器里打开 Netbeans 默认的更新地址：<a href="http://dlc.sun.com.edgesuite.net/netbeans/updates/6.8/uc/final/stable/catalog_zh_CN.xml.gz" target="_blank">http://dlc.sun.com.edgesuite.net/netbeans/updates/6.8/uc/final/stable/catalog_zh_CN.xml.gz</a>，404 错误，原来是插件目录文件不存在。</p>
<p>访问 <a href="http://dlc.sun.com.edgesuite.net/netbeans/updates/6.8/uc/final/stable/ " target="_blank">http://dlc.sun.com.edgesuite.net/netbeans/updates/6.8/uc/final/stable/</a> 得到插件目录文件 <a href="http://dlc.sun.com.edgesuite.net/netbeans/updates/6.8/uc/final/stable/catalog.xml.gz" target="_blank">http://dlc.sun.com.edgesuite.net/netbeans/updates/6.8/uc/final/stable/catalog.xml.gz</a>，通过“工具-&gt;插件-&gt;设置”添加这个插件目录作为更新中心的源。删除原来不存在的更新中心。PHP、C/C++ 的插件再次出现在可安装的插件列表里。</p>
<p>看来是多语言包出的问题啊！</p>
<p>跟进：<a href="https://netbeans.org/bugzilla/show_bug.cgi?id=178459" target="_blank">https://netbeans.org/bugzilla/show_bug.cgi?id=178459</a> 原来，更新中心的文件是对的，但是他们忘记发布了。</p>
]]></content:encoded>
			<wfw:commentRss>http://www.mikespook.com/index.php/archives/441/feed</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>Netbeans Python 调试，郁闷的包导入问题</title>
		<link>http://www.mikespook.com/index.php/archives/419</link>
		<comments>http://www.mikespook.com/index.php/archives/419#comments</comments>
		<pubDate>Tue, 10 Nov 2009 03:50:00 +0000</pubDate>
		<dc:creator>mikespook</dc:creator>
				<category><![CDATA[NetBeans]]></category>
		<category><![CDATA[Python]]></category>
		<category><![CDATA[调试]]></category>

		<guid isPermaLink="false">http://www.mikespook.com/?p=419</guid>
		<description><![CDATA[这几天在帮忙开发一个 python 项目。使用 netbeans 的时候，遇到一个诡异的问题。 如果使用“运行”来跑项目，一切正常。而如果使用“调试”来跑项目，当执行到 import 第三方的库的时候，就会产生“ImportError: No module named xxxx”。郁闷不已，上网查了半天，没找到可用的信息。 毛主席教育我们“自己动手，丰衣足食”。于是就祭出“观察、归纳和总结”的科学的研究方法，对这个灵异现象进行了一番探索。 出现导入问题的包都是用了 egg 打包的第三方包。在我的系统中，这几个包都是放在/usr/local/lib/python2.6/dist-packages/下。在命令行能正常执行，在 netbeans 中直接执行也无异常。说明包本身的安装没有问题。那么 netbeans 调试就出现找不到这个包，是不是 netbeans 的调试环境有什么特殊呢？看了一下 netbeans 的调试窗口，发现这个脚本~/.netbeans/6.7/config/nbPython/debug/nbpythondebug/jpydaemon.py。很明显，这个是 netbeans 为了集成调试功能而开发的一个 python 调试器。难道是这个netbeans自带的调试器的问题？祭出 sys.path 一看，果然正常执行的时候，dist-packages 下的 egg 包都被放到搜索路径里。而调试的时候，没有一个 egg 包在 sys.path 中。而是多了一些 netbeans 使用的目录而已。 郁闷啊，为什么调试器不能直接继承系统环境呢？ 于是乎，将每个 egg 包都手工加入 Python Platforms 的 Python Path 里。问题解决了。可以带第三方 egg 包来调试项目了。 虽然问题解决了，不过还是不爽，如果我一个项目要是有 n 个 egg [...]]]></description>
			<content:encoded><![CDATA[<p>这几天在帮忙开发一个 python 项目。使用 netbeans 的时候，遇到一个诡异的问题。</p>
<p>如果使用“运行”来跑项目，一切正常。而如果使用“调试”来跑项目，当执行到 import 第三方的库的时候，就会产生“ImportError: No module named xxxx”。郁闷不已，上网查了半天，没找到可用的信息。</p>
<p>毛主席教育我们“自己动手，丰衣足食”。于是就祭出“观察、归纳和总结”的科学的研究方法，对这个灵异现象进行了一番探索。<span id="more-419"></span></p>
<p>出现导入问题的包都是用了 egg 打包的第三方包。在我的系统中，这几个包都是放在/usr/local/lib/python2.6/dist-packages/下。在命令行能正常执行，在 netbeans 中直接执行也无异常。说明包本身的安装没有问题。那么 netbeans 调试就出现找不到这个包，是不是 netbeans 的调试环境有什么特殊呢？看了一下 netbeans 的调试窗口，发现这个脚本~/.netbeans/6.7/config/nbPython/debug/nbpythondebug/jpydaemon.py。很明显，这个是 netbeans 为了集成调试功能而开发的一个 python 调试器。难道是这个netbeans自带的调试器的问题？祭出 sys.path 一看，果然正常执行的时候，dist-packages 下的 egg 包都被放到搜索路径里。而调试的时候，没有一个 egg 包在 sys.path 中。而是多了一些 netbeans 使用的目录而已。</p>
<p>郁闷啊，为什么调试器不能直接继承系统环境呢？</p>
<p>于是乎，将每个 egg 包都手工加入 Python Platforms 的 Python Path 里。问题解决了。可以带第三方 egg 包来调试项目了。</p>
<p>虽然问题解决了，不过还是不爽，如果我一个项目要是有 n 个 egg 包，那不是要每个都设置一下？</p>
<p>Hacking……</p>
<p>发现 jpydaemon.py 的 1588 行修改了sys.path，导致默认的路径信息丢失。</p>

<div class="wp_syntax"><div class="code"><pre class="python" style="font-family:monospace;">pythonPath = dbgutils.<span style="color: black;">PythonPathHandler</span><span style="color: black;">&#40;</span><span style="color: #008000;">None</span><span style="color: black;">&#41;</span>
pythonPath.<span style="color: black;">getPyPathFromEnv</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span></pre></div></div>

<p>再检查 dbgutils.py ，原来 netbeans 的调试环境只读取了环境变量 PYTHONPATH，未添加默认的 sys.path。而我并没有使用 PYTHONPATH 环境变量，所以导致一些安装好的包无法导入。164 行直接覆盖了 sys.path。</p>

<div class="wp_syntax"><div class="code"><pre class="python" style="font-family:monospace;">    <span style="color: #ff7700;font-weight:bold;">def</span> getPyPathFromEnv<span style="color: black;">&#40;</span> <span style="color: #008000;">self</span> <span style="color: black;">&#41;</span>:
        <span style="color: #483d8b;">&quot;PYTHONPATH env and set sys.path out of it &quot;</span>
        pyPath = <span style="color: #dc143c;">os</span>.<span style="color: black;">environ</span><span style="color: black;">&#91;</span><span style="color: #483d8b;">&quot;PYTHONPATH&quot;</span><span style="color: black;">&#93;</span>
        <span style="color: #808080; font-style: italic;"># cleanly take care of previous ';' convention</span>
        <span style="color: #ff7700;font-weight:bold;">if</span> <span style="color: #dc143c;">os</span>.<span style="color: black;">pathsep</span> <span style="color: #66cc66;">!</span>= <span style="color: #483d8b;">';'</span>:
            pyPath.<span style="color: black;">replace</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">';'</span> , <span style="color: #dc143c;">os</span>.<span style="color: black;">pathsep</span><span style="color: black;">&#41;</span>
        <span style="color: #ff7700;font-weight:bold;">if</span> pyPath.<span style="color: black;">find</span><span style="color: black;">&#40;</span><span style="color: #dc143c;">os</span>.<span style="color: black;">pathsep</span><span style="color: black;">&#41;</span> <span style="color: #66cc66;">!</span>= -<span style="color: #ff4500;">1</span>:
            <span style="color: #dc143c;">sys</span>.<span style="color: black;">path</span> = pyPath.<span style="color: black;">split</span><span style="color: black;">&#40;</span><span style="color: #dc143c;">os</span>.<span style="color: black;">pathsep</span><span style="color: black;">&#41;</span>
            <span style="color: #808080; font-style: italic;"># remove empty nodes first</span>
            <span style="color: #ff7700;font-weight:bold;">for</span> element <span style="color: #ff7700;font-weight:bold;">in</span> <span style="color: #dc143c;">sys</span>.<span style="color: black;">path</span>:
                <span style="color: #ff7700;font-weight:bold;">if</span> <span style="color: black;">&#40;</span> <span style="color: #008000;">len</span><span style="color: black;">&#40;</span>element.<span style="color: black;">strip</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span><span style="color: black;">&#41;</span>==<span style="color: #ff4500;">0</span> <span style="color: black;">&#41;</span>:
                    <span style="color: #dc143c;">sys</span>.<span style="color: black;">path</span>.<span style="color: black;">remove</span><span style="color: black;">&#40;</span>element<span style="color: black;">&#41;</span></pre></div></div>

<p>修改 164 行</p>

<div class="wp_syntax"><div class="code"><pre class="python" style="font-family:monospace;"><span style="color: #dc143c;">sys</span>.<span style="color: black;">path</span> = pyPath.<span style="color: black;">split</span><span style="color: black;">&#40;</span><span style="color: #dc143c;">os</span>.<span style="color: black;">pathsep</span><span style="color: black;">&#41;</span> + <span style="color: #dc143c;">sys</span>.<span style="color: black;">path</span></pre></div></div>

<p>这个世界又清爽了……</p>
<p>不知道会不会有什么问题。有问题，继续 fix 好了。</p>
]]></content:encoded>
			<wfw:commentRss>http://www.mikespook.com/index.php/archives/419/feed</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>在游戏中使用脚本语言</title>
		<link>http://www.mikespook.com/index.php/archives/330</link>
		<comments>http://www.mikespook.com/index.php/archives/330#comments</comments>
		<pubDate>Fri, 22 May 2009 05:55:34 +0000</pubDate>
		<dc:creator>mikespook</dc:creator>
				<category><![CDATA[Game]]></category>
		<category><![CDATA[NetBeans]]></category>
		<category><![CDATA[Demo]]></category>
		<category><![CDATA[Scripting]]></category>
		<category><![CDATA[游戏]]></category>

		<guid isPermaLink="false">http://www.mikespook.com/?p=330</guid>
		<description><![CDATA[这只是一个有趣的探索，demo 使用 java 编写。模拟了一个龙与地下城类 RPG 游戏中，在不同的房间内移动的简单游戏场景。 阅读本文前，首先下载使用 Netbeans 6.5 建立的完整项目代码：下载。然后，我会用 UML 图的方式来说明如何在游戏中使用脚本，其中可能还会简介一下游戏中实体对象的建立和管理（不知道值得不值得另外写一篇文章来介绍了）。 I have a dream&#8230; 现在要构建一个极为无聊的小世界。说它小，是因为我只打算让它有三个房间，三个房间之间两两互通的门。仅此而已。首先上图： 我们假设左边上面的房间叫 room-1，右边上面的房间叫 room-2，下面的房间叫 room-3。玩家在这三个房间中穿行，当然，不可能是穿墙。人，一定是要走门的。如图。就这么简单的逻辑而已，不用脚本语言也能轻松完成。不过如果希望多来一点拓展性呢？比如，room-3 不允许等级在5级以下玩家进入；room-2 当十级以上玩家进入后就会自动瞬间移动到 room-1；门锁住以后就不能通过，更夸张一点，门锁住以后如果不把锁打坏就不能通过……可能性太多了。不用脚本的情况下，如果要将这么多都实现，是一件非常繁琐的事情。 好吧，让我们来看看那些游戏公司是怎么解决这个问题的。哦，需要说明的是，这里的解决方案仅仅是一个 demo，只用来解释原理。真正的环境中，还要更复杂一点，不过也就是复杂一点点而已。 游戏中实体类如图设计，为了简化期间，没有实体管理器，所以也没有集成自统一的父类。 Ninny 类也就是玩家，有保存当前所在房间的成员变量。Room 类也就是房间，保存有在当前房间的玩家列表。Door 是描述门的类，保存了这个门连接的两个房间的列表。 为了简单期间，demo 中使用了 java 内置的 javascript 作为脚本语言，详情看这里。 本来还想多写一点的，急着出门。算了，反正有代码，大家看看先。有空回头写。重点在 js 目录下的那几个脚本 enterDoor.js，exitDoor.js，enterRoom.js，exitRoom.js。 好，继续！ 为了用起来方便，稍稍封装了一下Scripting的代码。大家直接看代码，不说话： 1 2 3 4 5 6 7 8 9 10 11 12 [...]]]></description>
			<content:encoded><![CDATA[<p>这只是一个有趣的探索，demo 使用 java 编写。模拟了一个龙与地下城类 RPG 游戏中，在不同的房间内移动的简单游戏场景。</p>
<p>阅读本文前，首先下载使用 Netbeans 6.5 建立的完整项目代码：<a href="http://www.mikespook.com/wp-content/uploads/2009/05/gamescripting.zip">下载</a>。然后，我会用 UML 图的方式来说明如何在游戏中使用脚本，其中可能还会简介一下游戏中实体对象的建立和管理（不知道值得不值得另外写一篇文章来介绍了）。</p>
<p>I have a dream&#8230;<span id="more-330"></span></p>
<p>现在要构建一个极为无聊的小世界。说它小，是因为我只打算让它有三个房间，三个房间之间两两互通的门。仅此而已。首先上图：<a href="http://www.mikespook.com/wp-content/uploads/2009/05/rooms.gif"><img class="alignright size-full wp-image-333" title="三个房间" src="http://www.mikespook.com/wp-content/uploads/2009/05/rooms.gif" alt="三个房间" width="241" height="241" /></a></p>
<p>我们假设左边上面的房间叫 room-1，右边上面的房间叫 room-2，下面的房间叫 room-3。玩家在这三个房间中穿行，当然，不可能是穿墙。人，一定是要走门的。如图。就这么简单的逻辑而已，不用脚本语言也能轻松完成。不过如果希望多来一点拓展性呢？比如，room-3 不允许等级在5级以下玩家进入；room-2 当十级以上玩家进入后就会自动瞬间移动到 room-1；门锁住以后就不能通过，更夸张一点，门锁住以后如果不把锁打坏就不能通过……可能性太多了。不用脚本的情况下，如果要将这么多都实现，是一件非常繁琐的事情。</p>
<p>好吧，让我们来看看那些游戏公司是怎么解决这个问题的。哦，需要说明的是，这里的解决方案仅仅是一个 demo，只用来解释原理。真正的环境中，还要更复杂一点，不过也就是复杂一点点而已。</p>
<p><a href="http://www.mikespook.com/wp-content/uploads/2009/05/gamescripting-e7b1bbe59bbe-1.jpg"><img class="alignleft size-medium wp-image-334" title="类图" src="http://www.mikespook.com/wp-content/uploads/2009/05/gamescripting-e7b1bbe59bbe-1-300x211.jpg" alt="类图" width="300" height="211" /></a>游戏中实体类如图设计，为了简化期间，没有实体管理器，所以也没有集成自统一的父类。</p>
<p>Ninny 类也就是玩家，有保存当前所在房间的成员变量。Room 类也就是房间，保存有在当前房间的玩家列表。Door 是描述门的类，保存了这个门连接的两个房间的列表。</p>
<p>为了简单期间，demo 中使用了 java 内置的 javascript 作为脚本语言，详情看<a href="http://java.sun.com/developer/technicalArticles/J2SE/Desktop/scripting/" target="_blank">这里</a>。</p>
<p><span style="text-decoration: line-through;">本来还想多写一点的，急着出门。算了，反正有代码，大家看看先。有空回头写。重点在 js 目录下的那几个脚本 enterDoor.js，exitDoor.js，enterRoom.js，exitRoom.js。</span></p>
<p>好，继续！</p>
<p>为了用起来方便，稍稍封装了一下Scripting的代码。大家直接看代码，不说话：</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
</pre></td><td class="code"><pre class="java" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">java.io.FileNotFoundException</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">java.io.FileReader</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">java.util.logging.Level</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">java.util.logging.Logger</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">javax.script.ScriptEngine</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">javax.script.ScriptEngineManager</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">javax.script.ScriptException</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">class</span> Script <span style="color: #009900;">&#123;</span>
&nbsp;
    <span style="color: #000000; font-weight: bold;">private</span> <span style="color: #000000; font-weight: bold;">final</span> <span style="color: #000000; font-weight: bold;">static</span> ScriptEngineManager factory <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> ScriptEngineManager<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #000000; font-weight: bold;">private</span> <span style="color: #000000; font-weight: bold;">final</span> <span style="color: #000000; font-weight: bold;">static</span> ScriptEngine engine <span style="color: #339933;">=</span> factory.<span style="color: #006633;">getEngineByName</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;JavaScript&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">void</span> put<span style="color: #009900;">&#40;</span><span style="color: #003399;">String</span> key, <span style="color: #003399;">Object</span> value<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        engine.<span style="color: #006633;">put</span><span style="color: #009900;">&#40;</span>key, value<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
&nbsp;
    <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #003399;">Object</span> get<span style="color: #009900;">&#40;</span><span style="color: #003399;">String</span> key<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        <span style="color: #000000; font-weight: bold;">return</span> engine.<span style="color: #006633;">get</span><span style="color: #009900;">&#40;</span>key<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
&nbsp;
    <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #003399;">Object</span> eval<span style="color: #009900;">&#40;</span><span style="color: #003399;">String</span> fileName<span style="color: #009900;">&#41;</span> <span style="color: #000000; font-weight: bold;">throws</span> ScriptException <span style="color: #009900;">&#123;</span>
        <span style="color: #000000; font-weight: bold;">try</span> <span style="color: #009900;">&#123;</span>
            <span style="color: #000000; font-weight: bold;">return</span> engine.<span style="color: #006633;">eval</span><span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">new</span> <span style="color: #003399;">FileReader</span><span style="color: #009900;">&#40;</span><span style="color: #003399;">System</span>.<span style="color: #006633;">getProperty</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;user.dir&quot;</span>, <span style="color: #0000ff;">&quot;.&quot;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">+</span> <span style="color: #0000ff;">&quot;/js/&quot;</span> <span style="color: #339933;">+</span> fileName <span style="color: #339933;">+</span> <span style="color: #0000ff;">&quot;.js&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #009900;">&#125;</span> <span style="color: #000000; font-weight: bold;">catch</span> <span style="color: #009900;">&#40;</span><span style="color: #003399;">FileNotFoundException</span> ex<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
            Logger.<span style="color: #006633;">getLogger</span><span style="color: #009900;">&#40;</span>Script.<span style="color: #000000; font-weight: bold;">class</span>.<span style="color: #006633;">getName</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">log</span><span style="color: #009900;">&#40;</span>Level.<span style="color: #006633;">SEVERE</span>, <span style="color: #000066; font-weight: bold;">null</span>, ex<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #009900;">&#125;</span>
        <span style="color: #000000; font-weight: bold;">return</span> <span style="color: #000066; font-weight: bold;">null</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

<p>从类图上可以看到，Door 和 Room 都实现了 Enterable 接口，两个方法：一个入 enter，一个出 exit。显然，当进入一个 Room 的时候，必须从另外一个房间出来。为了保证这个一致性，所以限定玩家不能穿墙只能走门：</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
</pre></td><td class="code"><pre class="java" style="font-family:monospace;">        Room r1 <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> Room<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;room-1&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        Room r2 <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> Room<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;room-2&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        Door d12 <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> Door<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        d12.<span style="color: #006633;">add</span><span style="color: #009900;">&#40;</span>r1<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        d12.<span style="color: #006633;">add</span><span style="color: #009900;">&#40;</span>r2<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        Ninny player <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> Ninny<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;ninny&quot;</span>, r1<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        d12.<span style="color: #006633;">enter</span><span style="color: #009900;">&#40;</span>player<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

<p>在不用脚本的情况下怎么写这个 Door 的 enter 方法呢？首先判断一下 ninny 是不是跟 Door 在同一个房间；获得 ninny 的当前房间后 exit；获得门另一端的房间 enter。就是这么简单。不过考虑到前面说说的那种种可能性，为了拓展让我们来看一看用脚本是如何处理的：</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
</pre></td><td class="code"><pre class="java" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">// Door 的 enter 方法</span>
    <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">boolean</span> enter<span style="color: #009900;">&#40;</span>Ninny ninny<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        Room currentRoom <span style="color: #339933;">=</span> ninny.<span style="color: #006633;">getOwner</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #666666; font-style: italic;">// 玩家在当前门所在的房间</span>
        <span style="color: #000000; font-weight: bold;">if</span><span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span>member.<span style="color: #006633;">containsKey</span><span style="color: #009900;">&#40;</span>currentRoom.<span style="color: #006633;">getName</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
            <span style="color: #000000; font-weight: bold;">return</span> <span style="color: #000066; font-weight: bold;">false</span><span style="color: #339933;">;</span>
        <span style="color: #009900;">&#125;</span>
        <span style="color: #666666; font-style: italic;">// 门另一侧的房间</span>
        Room nextRoom <span style="color: #339933;">=</span> getAnotherRoom<span style="color: #009900;">&#40;</span>currentRoom<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
        <span style="color: #000000; font-weight: bold;">try</span> <span style="color: #009900;">&#123;</span>
            Script script <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> Script<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
            script.<span style="color: #006633;">put</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;room1&quot;</span>, currentRoom<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
            script.<span style="color: #006633;">put</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;room2&quot;</span>, nextRoom<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
            script.<span style="color: #006633;">put</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;door&quot;</span>, <span style="color: #000000; font-weight: bold;">this</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
            script.<span style="color: #006633;">put</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;player&quot;</span>, ninny<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
            script.<span style="color: #006633;">eval</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;enterDoor&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
            <span style="color: #003399;">System</span>.<span style="color: #006633;">out</span>.<span style="color: #006633;">println</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;enterDoor: &quot;</span> <span style="color: #339933;">+</span> script.<span style="color: #006633;">get</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;message&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
            <span style="color: #000000; font-weight: bold;">return</span> <span style="color: #003399;">Boolean</span>.<span style="color: #006633;">valueOf</span><span style="color: #009900;">&#40;</span>script.<span style="color: #006633;">get</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;result&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">toString</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #009900;">&#125;</span> <span style="color: #000000; font-weight: bold;">catch</span> <span style="color: #009900;">&#40;</span>ScriptException ex<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
            Logger.<span style="color: #006633;">getLogger</span><span style="color: #009900;">&#40;</span>Door.<span style="color: #000000; font-weight: bold;">class</span>.<span style="color: #006633;">getName</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">log</span><span style="color: #009900;">&#40;</span>Level.<span style="color: #006633;">SEVERE</span>, <span style="color: #000066; font-weight: bold;">null</span>, ex<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
            <span style="color: #000000; font-weight: bold;">return</span> <span style="color: #000066; font-weight: bold;">false</span><span style="color: #339933;">;</span>
        <span style="color: #009900;">&#125;</span>        
    <span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

<p>这里实际上 enter 什么也没有做，只是传递了一些数据到 Script，然后执行了 enterDoor 这个脚本：</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
</pre></td><td class="code"><pre class="javascript" style="font-family:monospace;">importClass<span style="color: #009900;">&#40;</span>Packages.<span style="color: #660066;">foobar</span>.<span style="color: #660066;">Room</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
importClass<span style="color: #009900;">&#40;</span>Packages.<span style="color: #660066;">foobar</span>.<span style="color: #660066;">Ninny</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
importClass<span style="color: #009900;">&#40;</span>Packages.<span style="color: #660066;">foobar</span>.<span style="color: #660066;">Door</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
room1.<span style="color: #660066;">exit</span><span style="color: #009900;">&#40;</span>player<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
room2.<span style="color: #660066;">enter</span><span style="color: #009900;">&#40;</span>player<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #003366; font-weight: bold;">var</span> message <span style="color: #339933;">=</span> player.<span style="color: #660066;">getName</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">+</span> <span style="color: #3366CC;">&quot; enter from the room &quot;</span> <span style="color: #339933;">+</span> room1.<span style="color: #660066;">getName</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">+</span>  <span style="color: #3366CC;">&quot; to the romm &quot;</span> <span style="color: #339933;">+</span> room2.<span style="color: #660066;">getName</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">+</span> <span style="color: #3366CC;">&quot;!&quot;</span><span style="color: #339933;">;</span>
<span style="color: #003366; font-weight: bold;">var</span> result <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">true</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

<p>脚本也很简单，只是让玩家推出当前房间，进入下一个房间。如果房间对进入的玩家有等级要求，则只需：</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
</pre></td><td class="code"><pre class="javascript" style="font-family:monospace;">importClass<span style="color: #009900;">&#40;</span>Packages.<span style="color: #660066;">foobar</span>.<span style="color: #660066;">Room</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
importClass<span style="color: #009900;">&#40;</span>Packages.<span style="color: #660066;">foobar</span>.<span style="color: #660066;">Ninny</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
importClass<span style="color: #009900;">&#40;</span>Packages.<span style="color: #660066;">foobar</span>.<span style="color: #660066;">Door</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #003366; font-weight: bold;">var</span> result <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">false</span><span style="color: #339933;">;</span>
<span style="color: #003366; font-weight: bold;">var</span> message <span style="color: #339933;">=</span> <span style="color: #3366CC;">''</span><span style="color: #339933;">;</span>
<span style="color: #000066; font-weight: bold;">if</span><span style="color: #009900;">&#40;</span>room2.<span style="color: #660066;">needLevel</span> <span style="color: #339933;">&gt;=</span> player.<span style="color: #660066;">level</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    room1.<span style="color: #660066;">exit</span><span style="color: #009900;">&#40;</span>player<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    room2.<span style="color: #660066;">enter</span><span style="color: #009900;">&#40;</span>player<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
    message <span style="color: #339933;">=</span> player.<span style="color: #660066;">getName</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">+</span> <span style="color: #3366CC;">&quot; enter from the room &quot;</span> <span style="color: #339933;">+</span> room1.<span style="color: #660066;">getName</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">+</span>  <span style="color: #3366CC;">&quot; to the romm &quot;</span> <span style="color: #339933;">+</span> room2.<span style="color: #660066;">getName</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">+</span> <span style="color: #3366CC;">&quot;!&quot;</span><span style="color: #339933;">;</span>
    result <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">true</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span> <span style="color: #000066; font-weight: bold;">else</span> <span style="color: #009900;">&#123;</span>
    message <span style="color: #339933;">=</span> player.<span style="color: #660066;">getName</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">+</span> <span style="color: #3366CC;">&quot; can't enter the romm &quot;</span> <span style="color: #339933;">+</span> room2.<span style="color: #660066;">getName</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">+</span> <span style="color: #3366CC;">&quot;! Level&quot;</span> <span style="color: #339933;">+</span> room2.<span style="color: #660066;">needLevel</span> <span style="color: #339933;">+</span><span style="color: #3366CC;">&quot; needed!&quot;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

<p>在我的例子代码中并没有这部分代码，实际上 Room、Door、Ninny 这几个类都应该从一个父类 Entity 中继承。这个 Entity 有一个 Map<String, Object> 的成员变量。通过 setAttr(String, Object) 和 getAttr(String) 两个方法就可以分别设置和获取每个 Entity 的属性。这样就可以在脚本中自由的使用各种属性来实现各种功能。<br />
通过 Enterable（可进入），Pickable（可捡起），Attackable（可攻击）等接口，调用对应的脚本来完成真正的游戏逻辑。<br />
其实那神秘的游戏脚本化就是这么简单。本来还想画几个序列图说明一下脚本的调用，实在有些困了。<br />
准备洗洗睡觉。尚未补充完整的内容，全当大家进阶学习吧。</p>
]]></content:encoded>
			<wfw:commentRss>http://www.mikespook.com/index.php/archives/330/feed</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>在 Netbeans 6.5 中运行和调试基于 Darkstar 的服务器程序</title>
		<link>http://www.mikespook.com/index.php/archives/247</link>
		<comments>http://www.mikespook.com/index.php/archives/247#comments</comments>
		<pubDate>Thu, 04 Dec 2008 08:43:45 +0000</pubDate>
		<dc:creator>mikespook</dc:creator>
				<category><![CDATA[NetBeans]]></category>
		<category><![CDATA[Darkstar]]></category>
		<category><![CDATA[MMO]]></category>
		<category><![CDATA[Web game]]></category>
		<category><![CDATA[设置]]></category>

		<guid isPermaLink="false">http://www.mikespook.com/?p=247</guid>
		<description><![CDATA[Web game 一直以来被大家认为是开发技术门槛低，推广容易的一种游戏形式。但是在我1年来开发 web game 积累下来的经验来看，没有服务器端的 web game 只能被当作玩具，而不是一个可以运营的游戏（当然关于 Web game 技术考量关于这个话题，是我可能要写的另外一篇文章了）。为了这个目的，最近特意研究了一下 Darkstar。 Darkstar 是 SUN 公司支持的一个开源的多人在线游戏（MMO）架构，它提供了任务、数据、信道以及会话管理等一系列的功能。使得开发人员可以更加专注的设计开发游戏相关逻辑，而不是服务器基本功能设计或负载调优等等重复的体力活。关于 Darkstar 的详细介绍，可能要写 N 篇文章来说明。先有个大概了解就好了。 基于 Darkstar 开发服务器端的时候，不需要自己写主类。只要按照 Darkstar 提供的标准实现如 AppListener 等等的接口，就可以将开发人员实现的相关功能加入 Darkstar 架构中执行。Darkstar 分别在 *nix 系统和 windows 系统提供了 sgs.sh 和 sgs.bat 两个脚本，以方便使用。 Netbeans 6.5 的发布，给沉闷的开发带来了一丝生气。即使是我那 512M 内存的运行 xubuntu 的笔记本，跑起 Netbeans 也如行云流水般流畅（Eclipse 的粉丝别砸我，Eclipse 我开都不敢开）。我一般是使用 Netbeans 编写 java 代码，上网找了一下，netbeans 的一个 [...]]]></description>
			<content:encoded><![CDATA[<p>Web game 一直以来被大家认为是开发技术门槛低，推广容易的一种游戏形式。但是在我1年来开发 web game 积累下来的经验来看，没有服务器端的 web game 只能被当作玩具，而不是一个可以运营的游戏（当然关于 Web game 技术考量关于这个话题，是我可能要写的另外一篇文章了）。为了这个目的，最近特意研究了一下 Darkstar。</p>
<p><a href="http://www.projectdarkstar.com/" target="_blank">Darkstar</a> 是 SUN 公司支持的一个开源的多人在线游戏（MMO）架构，它提供了任务、数据、信道以及会话管理等一系列的功能。使得开发人员可以更加专注的设计开发游戏相关逻辑，而不是服务器基本功能设计或负载调优等等重复的体力活。关于 Darkstar 的详细介绍，可能要写 N 篇文章来说明。先有个大概了解就好了。</p>
<p>基于 Darkstar 开发服务器端的时候，不需要自己写主类。只要按照 Darkstar 提供的标准实现如 AppListener 等等的接口，就可以将开发人员实现的相关功能加入 Darkstar 架构中执行。Darkstar 分别在 *nix 系统和 windows 系统提供了 sgs.sh 和 sgs.bat 两个脚本，以方便使用。</p>
<p><a href="http://www.netbeans.org/" target="_blank">Netbeans 6.5</a> 的发布，给沉闷的开发带来了一丝生气。即使是我那 512M 内存的运行 xubuntu 的笔记本，跑起 Netbeans 也如行云流水般流畅（Eclipse 的粉丝别砸我，Eclipse 我开都不敢开）。<span id="more-247"></span>我一般是使用 Netbeans 编写 java 代码，上网找了一下，netbeans 的一个 Darkstar 插件已经有一些时候没有更新了。这使得在 Netbeans 中开发 Darkstar 很不方便，不能直接运行，也不能调试。在研究了 sgs.sh 和 sgs.bat 之后发现，这两个脚本实际上只是设置了 java 命令的一些参数，使得 Darkstar 可以执行。那么将这些参数移入 Netbeans 就可以在其中直接运行和调试了（这篇<a href="http://www.projectdarkstar.com/component/option,com_smf/Itemid,120/topic,634.0" target="_blank">帖子</a>验证了这个想法）。</p>
<p>首先添加库的时候，除了设置类路径和 javadoc 外，还应将 sgs-server-0.9.7-sources.jar 设置到源中去，方便开发和调试。</p>
<p>然后在“项目属性”中找到“运行”，按照下表填写：</p>
<p>主类：com.sun.sgs.impl.kernel.Kernel</p>
<p>参数：foobar.properties</p>
<p>工作目录：F:\java\FoobarServer\data</p>
<p>VM 选项：-Djava.library.path=F:\java\libs\sgs\sgs-server-0.9.7\lib\bdb\win32-x86</p>
<p>其中<strong>主类</strong>是在项目导入的 sgs-server.jar 中的类。在任何环境下都只可以填写这个 Kernel 类。</p>
<p><strong>参数</strong>是项目的配置文件，这个文件一般有下面的内容：</p>
<p>com.sun.sgs.app.name=HelloFoobar<br />
com.sun.sgs.app.root=F:/java/FoobarServer/data/<br />
com.sun.sgs.app.port=1139<br />
com.sun.sgs.app.listener=com.xxiyy.game.server.FoobarServer</p>
<p>name 是项目名称。root 是项目根目录，跟目录必须含有子目录 dsdb，用来存储序列会对象数据。port 是服务器监听的端口。listener 即是实现 AppListener 接口的用户类了。需要注意的是，如果不是用绝对路径，properties 文件是相对于<strong>工作目录</strong>来说的。</p>
<p><strong>工作目录</strong>需要对应 properties 文件中的 root 选项。一定要注意，工作目录必须含有子目录 dsdb。否则运行的时候会提示无法找到路径的错误。</p>
<p><strong>VM 选项</strong>是因为 Darkstar 默认使用了Berkeley db，需要加载动态库文件。对于windows 就是 bdb 所带 win32-x86 目录中的 libdb_java45.dll。对于 32 位 linux 就是 linux-x86 目录中的 libdb-4.5.so 和 libdb_java-4.5.so。其他不同系统类推。如果你在运行后出现 java.lang.UnsatisfiedLinkError: no libdb_java45 in java.library.path 这样的异常，说明你的 java.library.path 没有设置正确。</p>
<p>确定后，就可以像普通 java 程序那样在 netbeans 中直接运行或调试 Darkstar 程序了。</p>
]]></content:encoded>
			<wfw:commentRss>http://www.mikespook.com/index.php/archives/247/feed</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>netbeans 6.5 rc 下建立 Zend Framework 项目</title>
		<link>http://www.mikespook.com/index.php/archives/205</link>
		<comments>http://www.mikespook.com/index.php/archives/205#comments</comments>
		<pubDate>Fri, 24 Oct 2008 04:37:13 +0000</pubDate>
		<dc:creator>mikespook</dc:creator>
				<category><![CDATA[NetBeans]]></category>
		<category><![CDATA[Zend Framework]]></category>

		<guid isPermaLink="false">http://www.mikespook.com/?p=205</guid>
		<description><![CDATA[首先，这不是一个指南，这只是一个简易说明。描述了如何在 netbeans 6.5 rc for php 中建立、开发、调试 Zend Framework 项目。 step by step: 1. 安装 netbeans 6.5 rc for php，由于 netbeans 6.5 rc for php 官方只放出了英文版本。中文版本要在这里下载。 2. 安装 xdebug，这不是必要的一部，不过如果你想在 netbeans 中调试 php。这是非常必要的。相关内容去 xdebug 官方网站了解，这里也有简单的说明。 3. 我假设你在安装 netbeans 6.5 rc for php 未遇到任何问题，如果遇到了，请参考 netbeans 的 FAQ 关于安装的部分。 4. 打开 netbeans 6.5 rc for php，在菜单中选择“新建项目”。当然更多时候 Ctrl+Shift+N 是一个更好的主意。 [...]]]></description>
			<content:encoded><![CDATA[<p>首先，这不是一个指南，这只是一个简易说明。描述了如何在 netbeans 6.5 rc for php 中建立、开发、调试 Zend Framework 项目。</p>
<p>step by step:<span id="more-205"></span></p>
<p>1. 安装 netbeans 6.5 rc for php，由于 netbeans 6.5 rc for php 官方只放出了<a href="http://download.netbeans.org/netbeans/6.5/rc/bundles/netbeans-6.5rc1-php-windows.exe" target="_blank">英文版本</a>。中文版本要在<a href="http://dlc.sun.com.edgesuite.net/netbeans/6.5/rc/" target="_blank">这里下载</a>。</p>
<p>2. 安装 xdebug，这不是必要的一部，不过如果你想在 netbeans 中调试 php。这是非常必要的。相关内容去 <a href="http://xdebug.org/" target="_blank">xdebug 官方网站</a>了解，<a href="http://www.mikespook.com/index.php/archives/34" target="_blank">这里</a>也有简单的说明。</p>
<p>3. 我假设你在安装 netbeans 6.5 rc for php 未遇到任何问题，如果遇到了，请参考 netbeans 的 <a href="http://wiki.netbeans.org/NetBeansUserFAQ#section-NetBeansUserFAQ-Installation" target="_blank">FAQ 关于安装的部分</a>。</p>
<p>4. 打开 netbeans 6.5 rc for php，在菜单中选择“新建项目”。当然更多时候 Ctrl+Shift+N 是一个更好的主意。</p>
<p><a href="http://www.mikespook.com/wp-content/uploads/2008/10/netbeans_for_php_1.jpg"><img class="alignnone size-medium wp-image-208" title="netbeans_for_php_1" src="http://www.mikespook.com/wp-content/uploads/2008/10/netbeans_for_php_1.jpg" alt="" width="296" height="128" /></a></p>
<p>5. 选择“PHP 应用程序”点下一步。也可以导入现有的代码，实际上两者并无本质区别。</p>
<p>6. 设置项目的名称以及存储目录。实际上这个存储目录需要将所有项目用到的文件，如代码、文档、配置都包含进去，否则开发时将遇到无穷无尽的从 netbeans 切换到其他工具，再切换回来的情况。而用到的不再进行修改的库文件，反而可以不用包含。</p>
<p><a href="http://www.mikespook.com/wp-content/uploads/2008/10/netbeans_for_php_7.jpg"><img class="alignnone size-medium wp-image-209" title="netbeans_for_php_7" src="http://www.mikespook.com/wp-content/uploads/2008/10/netbeans_for_php_7.jpg" alt="" width="148" height="99" /></a></p>
<p>7. 设置好名称和目录后，在“运行配置”中选择项目的部署方式，以及索引文件。通常本地开发网站，默认选择第一种方式即可。这时，netbeans 会默认以项目目录作为 webroot。索引文件可先随意选择一个项目目录中的文件。通常 Zend Framework 开发中 webroot 只是包含 index.php 入口和样式、图片等客户端使用的文件。例如目录“&lt;项目目录&gt;/www”。由于 Zend Framework 部署的特殊性，这里还要做修改。</p>
<p><a href="http://www.mikespook.com/wp-content/uploads/2008/10/netbeans_for_php_2.jpg"><img class="alignnone size-medium wp-image-210" title="netbeans_for_php_2" src="http://www.mikespook.com/wp-content/uploads/2008/10/netbeans_for_php_2-300x94.jpg" alt="" width="300" height="94" /></a></p>
<p>8. 在“项目”面板中选择刚才建立的 php 项目，点击鼠标右键选择菜单项“属性”。</p>
<p><a href="http://www.mikespook.com/wp-content/uploads/2008/10/netbeans_for_php_8.jpg"><img class="alignnone size-medium wp-image-211" title="netbeans_for_php_8" src="http://www.mikespook.com/wp-content/uploads/2008/10/netbeans_for_php_8-225x300.jpg" alt="" width="225" height="300" /></a></p>
<p>9. 在类别“源”的“Web 根目录”选择你真正的 webroot。例如：&lt;项目目录&gt;/www。</p>
<p><a href="http://www.mikespook.com/wp-content/uploads/2008/10/netbeans_for_php_3.jpg"><img class="alignnone size-medium wp-image-212" title="netbeans_for_php_3" src="http://www.mikespook.com/wp-content/uploads/2008/10/netbeans_for_php_3-300x84.jpg" alt="" width="300" height="84" /></a></p>
<p>10. 在“项目属性”的“运行配置”类别中，调整索引文件到 index.php。实际上，如果你完成了 step 9，这里会有一个“不是合法的索引文件”的警告。直到你重新调整索引文件为合法文件。</p>
<p><a href="http://www.mikespook.com/wp-content/uploads/2008/10/netbeans_for_php_4.jpg"><img class="alignnone size-medium wp-image-213" title="netbeans_for_php_4" src="http://www.mikespook.com/wp-content/uploads/2008/10/netbeans_for_php_4-300x72.jpg" alt="" width="300" height="72" /></a></p>
<p>11. 在“项目属性”的“PHP 包含路径”中设置你的 Zend Framework 路径。例如从 svn 导出的某个路径 ~/Zend Framework\library。</p>
<p><a href="http://www.mikespook.com/wp-content/uploads/2008/10/netbeans_for_php_5.jpg"><img class="alignnone size-medium wp-image-214" title="netbeans_for_php_5" src="http://www.mikespook.com/wp-content/uploads/2008/10/netbeans_for_php_5-300x99.jpg" alt="" width="300" height="99" /></a></p>
<p>12. 至此已经基本设置完成，需要注意的是“项目属性”中的“调试服务器端 PHP”和“调试客户端 JavaScript” 需要勾上才可以正常调试。</p>
<p><a href="http://www.mikespook.com/wp-content/uploads/2008/10/netbeans_for_php_6.jpg"><img class="alignnone size-medium wp-image-215" title="netbeans_for_php_6" src="http://www.mikespook.com/wp-content/uploads/2008/10/netbeans_for_php_6-300x90.jpg" alt="" width="300" height="90" /></a></p>
<p>简单测试一下代码编辑和调试的情况：</p>
<p><a href="http://www.mikespook.com/wp-content/uploads/2008/10/netbeans_for_php_9.jpg"><img class="alignnone size-medium wp-image-216" title="netbeans_for_php_9" src="http://www.mikespook.com/wp-content/uploads/2008/10/netbeans_for_php_9-283x300.jpg" alt="" width="283" height="300" /></a></p>
<p>漂亮完整的代码提示，包括方法或属性类型、参数、所在的类名或文件名等等。同时还会解析 phpdoc。</p>
<p><a href="http://www.mikespook.com/wp-content/uploads/2008/10/netbeans_for_php_10.jpg"><img class="alignnone size-medium wp-image-217" title="netbeans_for_php_10" src="http://www.mikespook.com/wp-content/uploads/2008/10/netbeans_for_php_10-300x94.jpg" alt="" width="300" height="94" /></a></p>
<p>强大的单步调试，我以前说过 php 让我头疼的就是调试。虽然 xdebug 很完美，但是所有调试器都有这样那样的不足。现在 netbeans 带来的是 java style 的调试方式，很好，很强大。</p>
<p><a href="http://www.mikespook.com/wp-content/uploads/2008/10/netbeans_for_php_11.jpg"><img class="alignnone size-medium wp-image-218" title="netbeans_for_php_11" src="http://www.mikespook.com/wp-content/uploads/2008/10/netbeans_for_php_11-300x176.jpg" alt="" width="300" height="176" /></a></p>
<p>变量的监视信息详实准确，无需再为一个变量的值而 echo 来 var_dump 去了。</p>
<p>总体上来说，netbeans 6.5rc for php 是我见过的比较好的 IDE for php 之一。即便我坚信 IDE is evil ，netbeans for php 也让我眼前一亮。再配合其他插件如 svn、uml、database，已经无需其他工具辅助即可完成 php 日常开发所需。不过试用之后，也发现一些不足的地方：比如有一些提示框中英文混杂在一起；新建 php 工程的向导设置也过于简单，以至于建立 Zend Framework 项目时需要建立好后再次调整项目设置；又比如会莫名其妙的提示一个临时目录下某文件无法访问；再如代码提示时不能正确解析魔法方法，无法提示魔法方法提供的魔法属性等等。不过相信在正式的 6.5 版中这些问题都会一一得到解决，作为一个 rc 版本的软件来说，netbeans 已经做得够好了。</p>
<p>我计划在 PNP-广州 PHP 街坊群中推荐 netbeans 作为初学 Zend Framework 的平台，这样可以利用强大的单步功能，和代码提示功能来学习 Zend Framework，了解 Zend Framework 的运行机制。不知道大家对此有什么看法和意见，欢迎讨论。</p>
<p>PS: 推荐 eclipse 的朋友务必请考虑一下我那只有 512M 内存的本本，当时选择用 netbeans 写 java，就是因为它不是那么消耗内存和 cpu。</p>
]]></content:encoded>
			<wfw:commentRss>http://www.mikespook.com/index.php/archives/205/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Netbeans 6 下使用 vim 的插件</title>
		<link>http://www.mikespook.com/index.php/archives/118</link>
		<comments>http://www.mikespook.com/index.php/archives/118#comments</comments>
		<pubDate>Tue, 29 Apr 2008 06:37:20 +0000</pubDate>
		<dc:creator>mikespook</dc:creator>
				<category><![CDATA[NetBeans]]></category>
		<category><![CDATA[viex]]></category>
		<category><![CDATA[vim]]></category>

		<guid isPermaLink="false">http://www.mikespook.com/?p=118</guid>
		<description><![CDATA[在厭倦了來回切換 gvim 和 netbeans，以及無數次向代碼中插入冒號之后，決定為 Netbeans 安裝一個 vim 插件。externaleditor 已經過分古舊。大概是對自己的編輯器很有信心吧, 官方沒有提供 6.0 的編輯器擴展方式。 在 sf 上找到了這個東東——VIEX，還可以，就像它介紹的那樣“Is not very good, but useful”。 不過遺憾的是，好像并不是直接內嵌 vim 到 netbeans。而是模擬了 vim 的使用方式。所以總有些用著不合適的地方。不過不管怎么說 :w 能存盤了。]]></description>
			<content:encoded><![CDATA[<p>在厭倦了來回切換 gvim 和 netbeans，以及無數次向代碼中插入冒號之后，決定為 Netbeans 安裝一個 vim 插件。externaleditor 已經過分古舊。大概是對自己的編輯器很有信心吧, 官方沒有提供 6.0 的編輯器擴展方式。</p>
<p>在 <a href="http://www.sf.net" target="_blank">sf</a> 上找到了這個東東——<a href="http://viex.sourceforge.net/" target="_blank">VIEX</a>，還可以，就像它介紹的那樣“Is not very good, but useful”。</p>
<p>不過遺憾的是，好像并不是直接內嵌 vim 到 netbeans。而是模擬了 vim 的使用方式。所以總有些用著不合適的地方。不過不管怎么說 :w 能存盤了。</p>
]]></content:encoded>
			<wfw:commentRss>http://www.mikespook.com/index.php/archives/118/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>NetBeans 6.0 正式发布了</title>
		<link>http://www.mikespook.com/index.php/archives/68</link>
		<comments>http://www.mikespook.com/index.php/archives/68#comments</comments>
		<pubDate>Tue, 11 Dec 2007 07:49:11 +0000</pubDate>
		<dc:creator>mikespook</dc:creator>
				<category><![CDATA[NetBeans]]></category>

		<guid isPermaLink="false">http://www.mikespook.com/index.php/archives/68</guid>
		<description><![CDATA[PHP 插件进入了官方升级列表里。 从 5.5.1 平行升级 6.0 没有问题。 尺寸比以前小了很多，基本 J2SE 功能的 IDE 只要 21M。 开启速度有些慢，比之前吃多了一些内存。但是使用的时候反而快了。 更细致的部分还在用，总得来说，我很喜欢。^_^]]></description>
			<content:encoded><![CDATA[<p>PHP 插件进入了官方升级列表里。</p>
<p>从 5.5.1 平行升级 6.0 没有问题。</p>
<p>尺寸比以前小了很多，基本 J2SE 功能的 IDE 只要 21M。</p>
<p>开启速度有些慢，比之前吃多了一些内存。但是使用的时候反而快了。</p>
<p>更细致的部分还在用，总得来说，我很喜欢。^_^</p>
]]></content:encoded>
			<wfw:commentRss>http://www.mikespook.com/index.php/archives/68/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>今天收到了NetBeans的光盘</title>
		<link>http://www.mikespook.com/index.php/archives/62</link>
		<comments>http://www.mikespook.com/index.php/archives/62#comments</comments>
		<pubDate>Wed, 31 Oct 2007 07:25:27 +0000</pubDate>
		<dc:creator>mikespook</dc:creator>
				<category><![CDATA[NetBeans]]></category>

		<guid isPermaLink="false">http://www.mikespook.com/index.php/archives/62</guid>
		<description><![CDATA[自己都快忘了这事了。快两个月，终于漂洋过海的送到了。 &#160; &#160;等6.0出来了，再去申请一张。感觉蛮好用。]]></description>
			<content:encoded><![CDATA[<p>自己都快忘了这事了。快两个月，终于漂洋过海的送到了。</p>
<p>&nbsp;<a href="/wp-content/uploads/2007/10/outside.jpg" onclick="return false;" title="Direct link to file"><img width="120" height="128" src="/wp-content/uploads/2007/10/outside.thumbnail.jpg" alt="封皮" /></a></p>
<div id="upload-file-view" class="alignleft">
<p><a href="/wp-content/uploads/2007/10/inside.jpg" onclick="return false;" title="Direct link to file"><img width="121" height="128" src="/wp-content/uploads/2007/10/inside.thumbnail.jpg" alt="光盘" /></a></p>
<p>&nbsp;等6.0出来了，再去申请一张。感觉蛮好用。</p>
</div>
]]></content:encoded>
			<wfw:commentRss>http://www.mikespook.com/index.php/archives/62/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
