1. closures, inner class and 函数指针

    一直不是很理解这三个感念之间的区别。Java是面向对象的编程语言,这点与现在流行的面向函数的动态编程语言不同。Javascript就是后者的一个例子。函数可以独立于对象存在,(或者说它本身就是一种对象)。   Java里没有函数指针,但可以向函数中传入一个匿名内部类模拟这种行为。   Java目前还未引入closures, 但基于JVM的Groovy已经有Closures概念。在Groovy中,所谓Closures就是一段大括号括起来的代码段。这段代码按照Java的习惯一般只能存在于函数中(初始化代码除外)并以函数名的方式调用。在Groovy中,这段代码可以赋给一个变量,通过这个变量来调用这段代码(很多时候放在大括号中直接匿名使用)。   那么代码段与Closures的区别是什么呢? 代码段一般是虚拟机碰到这段代码时就执行(方法调用,初始化,回调方法)。Closures只有在它的call()方法被调用时才执行。理解的不是很清楚,详细请参考:Closures Informal Guide   闭包有几个特点: 可以访问闭包范围外的变量(这点是不是跟Java中内部类相似?) 可以匿名用在任何允许用闭包的地方,比如Groovy的list的collect, each 调用中

    2017/02/12 iteye

  2. Oracle 笔记

    oracle Hints select  /*+ FIRST_ROWS(100) */  field1, field2,... from ... where ... 上面是Hints, 用于优化,告诉oracle 尽快返回前100行,适用于OLTP。还有ALL_ROWS,告诉Oracle用最少的资源处理所有行并一次返回。   FTS(全表扫描)可以并行,通过设置 DB_FILE_MULTIBLOCK_READ_COUNT 索引扫描不能并行,一般快些。 Oracle 提供了两种优化策略 一种是 Rule-base Optimizer    另一种是Cost-base Optimizer    

    2017/02/12 iteye

  3. 类的初始化

    类的初始化顺序: 静态初始化块 main函数中的输出(调用构造函数前) 实例的初始化块(初始化匿名内部类的地方) 构造函数初始化 import static java.lang.System.out; public class InitializerDemo { public InitializerDemo() { out.println("in constructor"); // Fourth } static { out.println("in static initializer"); // First } { out.println("in instance initializer"); // Third } public static void main(String[] args) { out.println("in main() method"); //second new InitializerDemo(); } }        

    2017/02/12 iteye

  4. AJAX学习笔记

    在用IFrame做Ajax时,需要考虑的有: 先定义隐藏的IFrame <iframe name="myIframe" src="blank.html" style="width:0px;height:0px" frameborder="0"> </iframe> 通过button,Href或者form提交,动态修改IFrame的src属性或者设置Href,Form的Target属性 如何在父窗口和IFrame页面传递数据 Three ways of Moving Data From an iframe to the Parent The iframe page can use it's own javascripts to transfer and place the data into the parent. <script> // - this is the script in the iframe results page var reps = document.getElementById('state_reps').innerHTML; parent.document.getElementById('results1').innerHTML = reps; </script>     The iframe page can pass its document object as an argument to a function in the parent, thereby allowing the parent to retrieve data from the iframe. <script> // - this is the script in parent page function showReps(doc){ var x = doc.getElementById('state_reps').innerHTML; document.getElementById('results2').innerHTML = x; } </script>     Place an onload event handler in the iframe tag in the parent document (this page). This method does not work with Netscape <iframe name="repIframe3" src="blank.html" onload="getIframeDoc()"></iframe> <script> function getIframeDoc(){ var iframeDoc = window.frames['repIframe3'].document; var sr = iframeDoc.getElementById('state_reps'); if (sr){ var reps3 = sr.innerHTML; document.getElementById('results3').innerHTML = reps3; } } </script>     <script> // - this is the script in the iframe results page parent.showReps(document); </script>

    2017/02/12 iteye

  5. Javascript 笔记

    正则表达式 //删除开头和结尾所有的空格 function trim(str) {   return str.replace(/(^\s+|\s+$)/g,''); } 注: ^ 开头 $ 结尾 \s 空格匹配 + 多次出现      g 全文匹配 i 忽略大小写   setTimeout(message, 3000);  3秒后执行函数message一次,如果要重复执行需要在message函数中再调用setTimeout一次    

    2017/02/12 iteye

  6. RESTful 笔记

    REST(Representational State Transfer)是 Roy Fielding 提出的一个描述互联系统架构风格的名词。   Another way to say REST is in HTTP, any request a client can make involves a URL and an HTTP method. With REST, the URL is designed to represent a noun and the HTTP method always maps to one of several standard verbs, which will be performed against that noun.In summary, each HTTP method will cause a well-defined action on the resource represented by the URL it operates on. The methods can be compared to SQL commands: GET is like "SELECT," DELETE is like "DELETE," POST is like "INSERT" with an auto-generated ID, and PUT is like "INSERT OR UPDATE IF EXISTS" with an ID specified.   REST 指的是一组架构约束条件和原则。满足这些约束条件和原则的应用程序或设计就是 RESTful. stateless 有利于scalabilty,cluster 客户端可用cache提高性能   分层 这表示组件无法了解它与之交互的中间层以外的组件,这是博士论文中提到的,不是很理解   Get/Put/Delete方法的幂等性     Security 与SOAP架构相比,REST架构的优点是: SOAP接口隐藏在SOAP Envelope中了,对外暴露的是相同的URL(对于同一个web service), 不利于代理服务器根据HTTP method做安全控制, 除非解析SOAP Envelope 内容。   SOAP 采用HTTP Post也不利于浏览器做cache

    2017/02/12 iteye

  7. Date in Java

    以下两个是同一个时间: UTC, Coordinated Universal Time (UTC), use time zone of  GMT   GMT, Greenwich Mean Time   标准时间  18:00 GMT = 18:00+00:00 在用java.text.SimpleDateFormat("yyyy-MM-dd HH:mm:ssZ"); 格式化时间时: Z表示的时间格式是+00:00 z表示的时间格式是UTC

    2017/02/12 iteye

  8. WPS "The URI length is greater than the Windows limit of 259 characters"

    http://publib.boulder.ibm.com/infocenter/imshelp1/v3r0/index.jsp?topic=/com.ibm.wspac6.doc/satsinst.html Shorten the temp directory used by WebSphere® Portal Server (WPS), following the steps described below:   Create a directory with a short name on the C drive, for example, C:\tmp. Start the WebSphere Portal Server V6.0, and using the WAS Administrative Console, navigate to the servers Application Servers > Portal server(注意此处是portal server, 而不是app server,否则无效) > Java™ and Process Management > Process Definition > Java Virtual Machine page. In the Generic JVM arguments, fill in: -Dworkspace.user.root=C:\tmp Save and re-start the WebSphere Portal Server。When the server restarts, it will then use the C:\tmp directory as the WebSphere Portal Server temp directory. This fixes the problem.   好像IBM有Pack针对这个问题,以上的可以作为一个workaround. 在以下WAS/WPS测试通过。   IBM WebSphere Application Server - ND, 6.0.2.9 Build Number: cf90614.22 Build Date: 4/7/06

    2017/02/12 iteye