首页 文章 精选 留言 我的

精选列表

搜索[翻译],共10000篇文章
优秀的个人博客,低调大师

WCF技术内幕》翻译16:第1部分_第4章_WCF101:概述

第4章:WCF101 概述 WCF框架是个复杂的框架,它的复杂性源于这样一个事实,在抽象层上,一个消息框架必须适应行业标准的不断更新和完善。在WCF设计阶段,SOAP和WS-*被认为是未来主流的消息结构和协议。当初任何一个负责WCF的架构师都不会想到JSON会有今天的地位。但是他们确实明白一个事实,WCF必须很好地兼容和适应那些新的消息结构和传输,就像现在的WCF一样。于是微软设计了高扩展性和适应性的WCF,不但可以满足今天消息需求,也可以满足未来不可预知的新的需求。这些努力的结果就是一个容易使用,但整体上有点难以理解的复杂平台 每个设计过一个大的框架(framework)的人都可以证明,设计、构建、测试和维护这个框架都是一个艰巨的任务。我曾经设计、讨论和构建过几个框架,明白这有多么的困难。当设计一个框架的时候,Alan Kay的名言 [老徐备注1]“简单的东西应该简单,复杂的东西才有可能成功”应该是首要原则。当在看现在的WCF,我想微软通过把许多复杂的东西简单化,已经成功地实现了这个名言,即使从长远来看也是如此。这不是说我认为WCF是完美的,没有错误,而是说,作为一个完整的产品,WCF是精心思考和设计良好的。 WCF核心需求之一就是暴露一个对象模型给开发者,这个对象模型可以兼容所有的传输和协议。具体化的例子就是,WCF团队的架构师希望通过TCP/IP发送消息的代码和通过MSMQ发送消息的代码看起来十分相似。这个特性有以下几个好处。第一,它意味着这个平台不强迫开发者学习各种不同传输和协议的对象模型。实际上,了解WCF对象和执行模型的开发者可以在他们的应用系统里实现对不同传输和协议的支持。第二,它意味着随着WCF的对新的传输、协议和功能的成功支持,开发者没有必要为了开发系统里新的功能而学习新的通信方式。相反,他们可以使用WCF框架里已经存在的通信机制。 由于这些类型的需求,WCF架构由许多交织的层组成。 随着时间的推移,我发现要向完全理解任何一个 WCF 基础架构里的一层,都需要首先理解 WCF 基础架构里每个层相关的一些概念。本章的目的就是要介绍 WCF 应用中主要的层次,为本书后面部分章节深入学习这些层次奠定坚实的基础。 【老徐备注】 1.Simple things should be simple ,complex things should be possible,Alan 是Smalltalk 面向对象编程环境语言的发明人之一,也是面向对象编程思想的创始人之一,他还是笔记本电脑最早的构想者和现代Windows GUI的建筑师(architect)。 本文转自 frankxulei 51CTO博客,原文链接:http://blog.51cto.com/frankxulei/318607 ,如需转载请自行联系原作者

优秀的个人博客,低调大师

《WCF技术内幕》翻译4:第1部分_第1章_蓝月亮:商业示例

商业示例所有的这些行业倡议和重大事记都会让你期待一个真实世界的面向服务的应用的例子,WCF可以办到。关于这个问题,我们可以看一下Contoso公司(虚拟的公司)的需求。在我们的例子里,Contoso 是一个世界领先的回飞棒制造商,目前,Contoso的回飞棒订单可以有区域销售代表、或者总部的客户服务中心、或者 Contoso 的网站在线完成。区域办公室,客户服务中心和网站包含各自的订单逻辑。改变订单逻辑需要升级各自的应用系统。图 1-1表示当前应用系统的拓扑结构。 为了例子,我们假设所有的发送订单的应用系统都有它们自己的订购逻辑的实现。如果订购商品的业务流程变化(可能是服从调整),所有的应用系统都必须改变,并且升级必须周密准备。这是非常昂贵和乏味的过程。 在接下来的6个月里,Contoso 希望各地的区域销售代表能够使用它们的手提设备下单。同样,公司高层多年也一直致力于推动合作伙伴使用它们的应用系统下单。在目前的架构 下,每个新的应用系统都需要实现它们自己的订购业务逻辑。对于手提设备来说可行,但是对于商业合作伙伴这样的情况却不太可能。结果,由于升级目前系统和新需求的成本,Contoso小而精干的开发团队已经制定了一个新的、统一的订单处理系统。 一个面向服务的选择对于当前的架构。如图 1-2所示,肩负解决更新和扩展问题的使命。 客观来说,这个例子有点勉强,但是基本原理很清晰。走进任何一个中间件或者大型的IT基础结构,你很可能看到许多类似的业务逻辑嵌套在多个系统中。一个简单的事实就是IT生存期增加了改变业务逻辑的成本,并且成为一个增加新的系统到企业内部的障碍。简单地说,WCF是一个可以让我们设计、构造和管理像图1-2里所示的应用系统,最终能够更好地去响应业务需求。 本文转自 frankxulei 51CTO博客,原文链接:http://blog.51cto.com/frankxulei/318643,如需转载请自行联系原作者

优秀的个人博客,低调大师

(摘取自官网,个人翻译…欢迎校正)

Activity Input validation: Test that an activity responds correctly to input values in an EditText View. Set up a keystroke sequence, send it to the activity, and then usefindViewById(int)to examine the state of the View. You can verify that a valid keystroke sequence enables an OK button, while an invalid one leaves the button disabled. You can also verify that the Activity responds to invalid input by setting error messages in the View. 输入验证:测试一个activity对EditText View输入做出正确地反应.设置按键顺序,并且发送到activity中,还有使用findViewById()用来验证View的状态是否正常.你可以验证一个有效的按键序列在OK按钮上是有效的,当输入一个无效的按键会使按钮失效.你也可以验证当输入无效的设置在View中activity会做出何种反应. Lifecycle events: Test that each of your application's activities handles lifecycle events correctly. In general, lifecycle events are actions, either from the system or from the user, that trigger a callback method such asonCreate()oronClick(). For example, an activity should respond to pause or destroy events by saving its state. Remember that even a change in screen orientation causes the current activity to be destroyed, so you should test that accidental device movements don't accidentally lose the application state. 生命周期事件:测试你每一个应用程序activity 的 handles 在 生命周期里面都是正确的.通常来讲,生命周期事件都是action动作,任何来自于系统或者用户,将会触发回调方法,例如onCreate()或者onClick().举个例子,一个activity应该对pause或者destoryed做出反应来并且保存它的状态.记住,实际上屏幕方向的改变事件会导致当前activity被销毁,所以你应该测试程序在设备运行中发生意外事件时不会偶然间丢失程序的状态. Intents: Test that each activity correctly handles the intents listed in the intent filter specified in its manifest. You can useActivityInstrumentationTestCase2to send mock Intents to the activity under test. Intens:测试每一个activity对指定在manifest的intent-filter里的intents做出正确的处理.你可以使用ActivityInstrumentationTestCase2发送一个模拟Intents 到activity 在测试中 Runtime configuration changes: Test that each activity responds correctly to the possible changes in the device's configuration while your application is running. These include a change to the device's orientation, a change to the current language, and so forth. Handling these changes is described in detail in the topicHandling Runtime Changes. 改变运行时的设置:在程序运行时,测试每个activity都能对可能改变的设备配置做出正确的响应.这些改变包括改变设备的屏幕方向,改变当前语言,等等.Handing这些改变具体描述在Handling Runtime Changes. Screen sizes and resolutions: Before you publish your application, make sure to test it on all of the screen sizes and densities on which you want it to run. You can test the application on multiple sizes and densities using AVDs, or you can test your application directly on the devices that you are targeting. For more information, see the topicSupporting Multiple Screens. 屏幕的兼容性:在你发布你的程序之前,请确认测试好所有你想运行的屏幕大小.你可以使用AVDs测试你的应用程式在多种屏幕大小下,或者你可以直接测试你的程序在目标设备上.更多的信息,可以看这篇Supporting Multiple Screens. Content Provider Test with resolver methods: Even though you can instantiate a provider object inProviderTestCase2, you should always test with a resolver object using the appropriate URI. This ensures that you are testing the provider using the same interaction that a regular application would use. 测试解析方法:尽管你可以在providerTestCase2中实现一个provider,但是你应该始终用一个resolver对象测试合适的 URI.这可以确保你正在测试的provider 是在同一个应用程序中使用同样的操作. Test a public provider as a contract: If you intent your provider to be public and available to other applications, you should test it as a contract. This includes the following ideas: 测试一个公共的provider的协定:如果你想你的provider是一个公共的和可被其它程序访问的,你应该测试它的协定.这里包括了一些主意: Test with constants that your provider publicly exposes. For example, look for constants that refer to column names in one of the provider's data tables. These should always be constants publicly defined by the provider. 测试provider所有公开的常量.比如,在常量中有个列名是归类在provider’s data表中.这些常量应该始终定义在你的provider中 Test all the URIs offered by your provider. Your provider may offer several URIs, each one referring to a different aspect of the data. TheNote Padsample, for example, features a provider that offers one URI for retrieving a list of notes, another for retrieving an individual note by it's database ID, and a third for displaying notes in a live folder. 测试Provider提供的所有URIs.Provider可能提供一些URIs在data中每个都涉及到不同的方式.例如在NOTE PAD 例子中,比如,一个provider提供一个uri 用于回收一个列表的笔记记录,另外一个使用databas Id用于回收一条笔记记录,和 还有一个用于显示笔记在一个折叠面板上 Test invalid URIs: Your unit tests should deliberately call the provider with an invalid URI, and look for errors. Good provider design is to throw an IllegalArgumentException for invalid URIs. 测试无效的URIs:你的单元测试应该故意的调用provider使用一个无效的URI,并且,查看这些错误.在使用无效的URIs时,好的provider的设计是会抛出一个IllegalArgumentException异常. Test the standard provider interactions: Most providers offer six access methods: query, insert, delete, update, getType, and onCreate(). Your tests should verify that all of these methods work. These are described in more detail in the topicContent Providers. 测试标准的provider的操作.很多 providers 提供6个访问方法:查询,插入,删除,更新,获取类型,和onCreate().你的测试应该验证所有这些方法都是正常运行的.这些的详细描述可参阅Content Providers. Test business logic: Don't forget to test the business logic that your provider should enforce. Business logic includes handling of invalid values, financial or arithmetic calculations, elimination or combining of duplicates, and so forth. A content provider does not have to have business logic, because it may be implemented by activities that modify the data. If the provider does implement business logic, you should test it. 测试业务逻辑:不要忘记测试业务逻辑你的provider是可以实现的.业务逻辑包括处理无效的数据,财务或者算术的计算,消除或者联级复制,等等.一个content provider 不要有太多的业务逻辑,因为,这可能导致改变数据时部分业务逻辑被实现.如果你的provider实现了业务逻辑,你应该测试它. services Ensure that theonCreate()is called in response toContext.startService()orContext.bindService(). Similarly, you should ensure thatonDestroy()is called in response toContext.stopService(),Context.unbindService(),stopSelf(), orstopSelfResult(). 确定onCreate()方法是响应Context.startService() 或者Context.binServ()的调用.同样,你应该确定onDestoy()方法是响应Context.stopService(),Context.unbindService(),stopSelf(), orstopSelfResult(). 的调用 Test that your Service correctly handles multiple calls fromContext.startService(). Only the first call triggersService.onCreate(), but all calls trigger a call toService.onStartCommand(). In addition, remember thatstartService()calls don't nest, so a single call toContext.stopService()orService.stopSelf()(but notstopSelf(int)) will stop the Service. You should test that your Service stops at the correct point. 测试Service在Context.startService()的多次调用下正常运行.只有在第一次调用时触发Service.onCreate().但是,其它所有的调用都在Service.onStartCommand()触发.另外,记住startService()不支持嵌套调用!还有单独调用Context.stopService()或者Service.stopSelf()(但是不是stopSelf(int))将会停止Service.你应该测试你的Service在正确的点上停止. Test any business logic that your Service implements. Business logic includes checking for invalid values, financial and arithmetic calculations, and so forth. 测试Service实现的是所有业务逻辑.这些业务逻辑包括检查无效的值,财务和算术运算,等等 本文转自 liam2199 博客,原文链接:http://blog.51cto.com/youxilua/772686 如需转载请自行联系原作者

优秀的个人博客,低调大师

微软推出新翻译神器:让物联网设备都说同一种话

如今越来越多的家用电器开始变得智能化,可以想象,未来我们将能够通过Win10手机或电脑控制所有事物,真正步入智能化生活。为了加快生活智能化进程,一直以来微软都将物联网作为主要发展对象之一,Windows10系统也有专门针对物联网的版本。 现在面临的问题是,我们能见到的各种智能设备都由不同的厂商生产,各自使用不同的API接口以及专用的应用。随着设备数量的不断增加,导致了用户体验的严重下降。现在为了打破这种混乱的局面,为用户提供统一的体验,同时也解放开发者,微软宣布了Open Translators to Things(OpenT2T)开源项目。 该项目的目标是,让开发者只需要写一次代码,就能够访问所有同类设备的相同功能,而不用关心这些设备来自哪一个生产厂商。微软开源该项目的目的是邀请开发者参与,为实现这种统一做出贡献。 微软还畅想,当实现了设备“语言”的统一之后,Cortana或者应用就可以采用这一标准从而为用户提供一致且愉悦的体验。 本文转自d1net(转载)

优秀的个人博客,低调大师

为什么 Docker 在引领虚拟化和云计算的新浪潮 【已翻译100%】

又是一年的OSCON之际,今年的技术领域关注在人们热烈讨论的云基础建设。其中更有趣的是刚开始起步的Docker,这是一个超轻量化容器应用,充满潜力。 我对Docker的服务副总裁James Turnbull非常着迷,他将会在大会上带来一场Docker的速成班。除了探究Docker是什么之外,我们还将导论云,开源贡献和得到一份真正的工作。 您曾经出版过关于不同linux方面的著作。您开始是如何探索linux的呢?是什么让您对linux如此热衷呢? 我想我第一次接触linux是在Debian刚发布不久的90年代中期。我在工作环境中曾先后使用过OS400,VAX/VMS和SunOS。开始我并没意识到这个"开源"的家伙有多强大。但当我发现Linux时,我突然拥有了一个具有桌面规格的电脑,它可以运行为internet提供动力的相同工具和服务。这是非常振奋人心的。而更重要的是它是免费的。我不需要花钱去买昂贵的硬件和操作系统软件来完成这些很酷的事。稍后我发现我不仅可以免费使用它,我还可以得到它的源码。如果出了问题或者我需要其他一些功能,我可以实际改动它(或最少可以尝试修复它)或告知其他可以修复它的人。这种对系统的完全拥有感和围绕开源而成立的胚胎期社区令我很惊奇。从那时起我就爱上了开源。 在您履历中写到“为了一份真实的工作”,而您已成为了Docker公司的副主席,您会将您其他的开源工作只当作爱好么? 这话跟我伙伴开的玩笑一样。正如很多极客一样,我会经常守在电脑旁,解决问题或者写一些东西。我伙伴嘲笑我说我有两份工作:我的“真实的“工作和我的开源工作。感谢在像Puppet和Docker这种开源环境中度过的这几年,我已经能够在激情的同时得到了回报。 开源贡献者们经常以那种方式来谈论他们的工作;在开源领域中爱好与职业的界线是很模糊的。您觉得这会产生积极还是消极的影响呢? 我认为在不同的领域中它即是积极的又是消极的。积极的是在我们工作中遇到的问题(如构建工具,修复bug,写文档等)的解决方案是可以分享的,而且希望可以简化他人的生活或使他们能够快速解决这类问题。而它又是消极的,因为对于接近我日常工作的事如此热衷会加剧"你一直都在“的感觉(意思是一直在忙却没有完成日常需要完成的工作,即要加班)。 我也意识到这些模糊的界线是如何影响到我们行业和开源社区的多样性的。在创业者的世界中有一种看法,即一个好的开发者需要有一个GitHub个人资料,并且为开源做过贡献。我很幸运能有可以为开源做贡献的时间,金钱和教育背景。但很多其他人没有这些特权,并且白种人,男性和受过良好教育等这些要求提高了很多开源社区的门槛。由这种对于“好“开发者的观点导致了有点封闭式的招聘循环,并且更大范围地延长了开源和我们行业中的单一性。我觉得这是我们急需改变的地方。 您是如何加入到Docker项目的? 我是在Solomon将它开源后不久偶然发现的。我对LXC和容器有一些了解(过去有工作于Solaris Zones和IBM硬件上的LPAR的经历)因此我决定进行一下尝试。我被它的简易使用震惊了。原先使用容器的经历给我留下了需要不断调试和培养的复杂生物的印象。但Docker却跳了出来。当我看到Docker和构建于Docker之上的以CI/CD为中心的工作流时我就被它迷住了。 Docker在虚拟化和云计算领域掀起了一股热潮。为什么人们会对它如此兴奋呢? 我觉得是因为它的轻量级特性和与它一起的工作流。它是一个快速,易于使用且以开发者为中心的DevOps工具。它的作用只是进行基础的打包和承载代码。开发者希望有一种工具可以将这个过程的细节抽象出来。他们只想看到他们的代码运行起来。当代码传送到别处时会与系统管理员产生各种冲突,结果会导致代码只能运行于开发环境。Docker通过将您的代码尽可能地移植化来完成这项工作,并将这个移植的过程变得更加友好简单。 在你看来Docker最令人激动的潜在用途是什么? 当然是构建过程了。我的意思是我看到很多家伙用容器做超大规模的部署,的确,你可以在一台主机上使用很多容器,而且速度也很快。但这并不比使用它进行自动化的开发-测试过程更让我激动。 Docker是如何区别于标准的虚拟化的呢? Docker是操作系统级的虚拟化技术。与需要通过中间层使虚拟机运行于硬件之上的hypervisor虚拟化技术不同,Docker容器运行于操作系统内核之上的用户空间中。这使得Docker容器更加轻量迅速。 你认为云技术开发已经深受开源开发影响了么? 我觉得开源软件已经紧紧地与云计算绑定到了一起。不论是运行于云中的软件还云中所支持的开发模型。开源软件很便宜,而且从性能和许可角度看它都有很高的性价比。 你认为Docker将会如何改变虚拟化和云环境?你认为云技术已有固定的轨迹,还是仍有重大改变的余地? 我提到早期超大规模计算世界里的许多容器和使用案例开发-测试-构建两者之间,我认为距离Docker的理想还有很大的差距。我满心期待大量的公司和供应商去拥抱Docker,在裸机和云计算之间,把它作为一个可替代的方案。 云技术的轨迹。我想我们已经看到,在过去的几年里发生的重大变化。我认为他们在我们做之前要做的更多。OpenStack和它是否能成功作为IAAS的替代方案或者DIY的云解决方案是个问题。我认为我们仅仅触及了潜在的PAAS,并且其成长和开发的空间还有许多的余地。这将是PAAS产品开发的有趣能力,不论是他们渐渐拥抱还是连接基于云的客户产品。 **您能给我们一个扼要报告关于我们应该从这一年的OSCON Docker演示上期待什么吗?**这是一个非常速成的Docker课程介绍。受众是开发者和系统管理员和那些想以一种比较容易上手的方式开始使用Docker。我们会教授如何使用Docker的基础知识和如何将其与你的日常工作流进行整合。

优秀的个人博客,低调大师

【JAVA集合框架一 】java集合框架官方介绍 Collections Framework Overview 集合框架总览 翻译 jav...

原文链接: https://docs.oracle.com/javase/8/docs/technotes/guides/collections/overview.html 原文内容也一并附加在本文最后. 简介: Java平台包含一个集合框架。 集合是表示一组对象的对象(如经典的Vector类)。 集合框架是用于表示和操作集合的统一体系结构,使集合可以独立于实现细节而被操纵。 集合框架的主要有点在于: 通过提供数据结构和算法减少编程工作量,因此您不必亲自编写它们。 通过提供数据结构和算法的高性能实现来提高性能。由于每个接口的各种实现都是可以互换的,因此可以通过切换实现来调整程序。 通过建立通用语言来回传递集合,提供不相关的API之间的互操作性。--可以部分理解为向上转型 多态 通过学习多个特定的集合API来减少学习API所需的工作量。 --通过自顶而下的API设计风格 不要求您实现特定的集合API来减少设计和实现API所需的工作量。--通过提供抽象类提供了很多默认实现 通过为集合和算法提供标准接口来操纵它们,从而促进软件重用。 集合框架包括: 集合接口。表示不同类型的集合,例如Set,List和Map。这些接口构成了框架的基础。 通用实现。集合接口的主要实现。 遗留实现。早期版本Vector和Hashtable中的集合类进行了改进,以实现集合接口。 特殊用途的实现。设计用于特殊情况的实现。这些实现展示非标准的性能特征,使用限制或行为。 并发实现。为高并发使用而设计的实现。 包装实现。将功能(如同步)添加到其他实现。 更简化便利的实现. 集合接口的高性能低复杂实现. 抽象实现。集合接口的部分实现,以促进自定义实现。 算法。collections中非常有用的静态方法,比如例如排序列表。 基础架构。为集合即可欧提供重要支持的接口。--就是一些其他辅助的,比如Iterable 数组工具类。基本类型和引用对象数组的实用函数。严格来说,并不是集合框架的一部分,这个特性与集合框架同时添加到Java平台,并依赖于相同的基础结构。 集合接口: 集合接口分为两大阵营,最基础的接口java.util.Collection,有下面这些后代: java.util.Setjava.util.SortedSetjava.util.NavigableSetjava.util.Queuejava.util.concurrent.BlockingQueuejava.util.concurrent.TransferQueuejava.util.Dequejava.util.concurrent.BlockingDeque 另外的一些集合接口派生于 java.util.Map 不过他们并是真正的集合。 但是,这些接口包含集合视角的操作,这些操作可以将它们作为集合进行操作。Map有以下后代: java.util.SortedMapjava.util.NavigableMapjava.util.concurrent.ConcurrentMapjava.util.concurrent.ConcurrentNavigableMap 集合中的许多修改方法是可选的. 也就是允许实现类并不必须要实现一个或者多个这种操作. 如果你尝试使用,将会抛出运行时异常UnsupportedOperationException 每个实现的文档必须指定支持哪些可选操作。 引入了几个术语来帮助本规范: 不支持修改操作的集合(如添加,删除和清除)称为不可修改,非不可修改的集合是可修改的。; 如果集合额外保证集合对象中没有任何可见的修改那么称之为为不可变,非不可变的就是可变的; 保证集合大小不变的的集合,即使元素可以变化更改,称之为固定大小,非固定大小的列表称之为可变大小; 支持快速(通常是固定时间)索引元素访问的List是随机访问(RandomAccess) List,比如arrayList,不支持快速索引访问的称之为顺序访问 (sequential access)List ,RandomAccess标记接口指明一个list具有支持随机访问的特性,这一点保证了你可以编写通用的算法代码,通过选择不同的随机访问还是顺序访问List,以达到更好的性能. 一些实现可以做到限制哪些元素(或者在Map场景下的键和值)可以被存储。可能的限制包括要求元素: 特定类型 不能为null 遵从一些自定的断言判断式(Obey some arbitrary predicate) 如果尝试往有限制的接口实现中添加不符合的元素,会出现运行时异常,比如 ClassCastException, IllegalArgumentException, or a NullPointerException. 如果尝试在有限制的实现中移除一个不符合条件的元素或者测试是否存在,会导致异常 不过一些受限制的集合支持这种用法. 集合实现: 集合的实现类一般遵从这样子的形式 < 实现特性>加上<接口名称>的形式 下表中列出了通用实现 通用实现类支持集合框架中所有的可选操作,并且对于元素没有任何的限制 他们都是非同步的 不过Collections类中包含了很多静态的工厂方法-synchronization wrappers同步包装器 可以在很多非同的集合中提供同步的功能. 所有新的实现都具有快速失败迭代器,它可以检测到非法的并发修改,并且快速而干净地(而不是报错异常)失败。 ps: fail-fast java集合框架中的一种机制,检测并发修改 AbstractCollection, AbstractSet, AbstractList, AbstractSequentialList 和 AbstractMap 为了减少实现接口所需代价,提供了核心集合框架的基本实现。 这些类的API文档准确描述了每种方法的实现方式, 因此实现者知道哪些方法必须被重写,考虑到具体实现类的基本操作的性能。 并发集合: 应用程序中使用多个线程的集合的必须仔细编程,这个一般叫做并发编程 Java平台包含对并发编程的广泛支持。有关详细信息,请参阅Java Concurrency Utilities。 由于集合经常被使用,各种支持并发编程的接口和集合的实现都被包含在这些API中 这些类型,超出了前面提到过的同步包装,提供了并发编程中经常需要用到的特性 并发接口 BlockingQueueTransferQueueBlockingDequeConcurrentMapConcurrentNavigableMap 并发实现类 LinkedBlockingQueueArrayBlockingQueuePriorityBlockingQueueDelayQueueSynchronousQueueLinkedBlockingDequeLinkedTransferQueueCopyOnWriteArrayListCopyOnWriteArraySetConcurrentSkipListSetConcurrentHashMapConcurrentSkipListMap 设计目标: 主要的设计目标是编写一个体积小概念强大的API 新功能与当前程序差别不大,这一点非常重要.而且,需要在现有的基础上增加 而不是替代他们。 而且,新的API必须足够强大,才能够提供前面所述的所有优势。 为了使核心接口的数量保持较小, 接口不会尝试捕捉诸如易变性,可修改性和可调节性之类的细微区别 相反,在核心接口中一些调用是可选的 使得实现类可以抛出一个UnsupportedOperationException异常指示出他们不支持指定的可选操作 集合实现者必须清楚地在文档中表明实现支持哪些可选操作。 为了使每个核心接口中的方法数量保持较小, 只有在以下情况下,接口才包含方法: 这是一项真正的基本操作:就其他方面可以被合理定义而言, 它是一个基本的操作, 有一个不可抗拒的性能因素导致重要的实现类将会想要去重写它 所有关于集合的表现形式的互操作性至关重要。 这包括数组,在不改变语言的情况下,不能直接实现Collection接口。 因此, 该框架包含的方法可以将集合移入数组,将数组视为集合,将Map视为集合。 原文内容: Skip to Content Collections Framework Overview Introduction The Java platform includes acollections framework. Acollectionis an object that represents a group of objects (such as the classicVectorclass). A collections framework is a unified architecture for representing and manipulating collections, enabling collections to be manipulated independently of implementation details. The primary advantages of a collections framework are that it: Reduces programming effortby providing data structures and algorithms so you don't have to write them yourself. Increases performanceby providing high-performance implementations of data structures and algorithms. Because the various implementations of each interface are interchangeable, programs can be tuned by switching implementations. Provides interoperability between unrelated APIsby establishing a common language to pass collections back and forth. Reduces the effort required to learn APIsby requiring you to learn multiple ad hoc collection APIs. Reduces the effort required to design and implement APIsby not requiring you to produce ad hoc collections APIs. Fosters software reuseby providing a standard interface for collections and algorithms with which to manipulate them. The collections framework consists of: Collection interfaces. Represent different types of collections, such as sets, lists, and maps. These interfaces form the basis of the framework. General-purpose implementations. Primary implementations of the collection interfaces. Legacy implementations. The collection classes from earlier releases,VectorandHashtable, were retrofitted to implement the collection interfaces. Special-purpose implementations. Implementations designed for use in special situations. These implementations display nonstandard performance characteristics, usage restrictions, or behavior. Concurrent implementations. Implementations designed for highly concurrent use. Wrapper implementations. Add functionality, such as synchronization, to other implementations. Convenience implementations. High-performance "mini-implementations" of the collection interfaces. Abstract implementations. Partial implementations of the collection interfaces to facilitate custom implementations. Algorithms. Static methods that perform useful functions on collections, such as sorting a list. Infrastructure. Interfaces that provide essential support for the collection interfaces. Array Utilities. Utility functions for arrays of primitive types and reference objects. Not, strictly speaking, a part of the collections framework, this feature was added to the Java platform at the same time as the collections framework and relies on some of the same infrastructure. Collection Interfaces Thecollection interfacesare divided into two groups. The most basic interface,java.util.Collection, has the following descendants: java.util.Set java.util.SortedSet java.util.NavigableSet java.util.Queue java.util.concurrent.BlockingQueue java.util.concurrent.TransferQueue java.util.Deque java.util.concurrent.BlockingDeque The other collection interfaces are based onjava.util.Mapand are not true collections. However, these interfaces containcollection-viewoperations, which enable them to be manipulated as collections.Maphas the following offspring: java.util.SortedMap java.util.NavigableMap java.util.concurrent.ConcurrentMap java.util.concurrent.ConcurrentNavigableMap Many of the modification methods in the collection interfaces are labeledoptional. Implementations are permitted to not perform one or more of these operations, throwing a runtime exception (UnsupportedOperationException) if they are attempted. The documentation for each implementation must specify which optional operations are supported. Several terms are introduced to aid in this specification: Collections that do not support modification operations (such asadd,removeandclear) are referred to asunmodifiable. Collections that are not unmodifiable aremodifiable. Collections that additionally guarantee that no change in theCollectionobject will be visible are referred to asimmutable. Collections that are not immutable aremutable. Lists that guarantee that their size remains constant even though the elements can change are referred to asfixed-size. Lists that are not fixed-size are referred to asvariable-size. Lists that support fast (generally constant time) indexed element access are known asrandom accesslists. Lists that do not support fast indexed element access are known assequential accesslists. TheRandomAccessmarker interface enables lists to advertise the fact that they support random access. This enables generic algorithms to change their behavior to provide good performance when applied to either random or sequential access lists. Some implementations restrict what elements (or in the case ofMaps, keys and values) can be stored. Possible restrictions include requiring elements to: Be of a particular type. Be not null. Obey some arbitrary predicate. Attempting to add an element that violates an implementation's restrictions results in a runtime exception, typically aClassCastException, anIllegalArgumentException, or aNullPointerException. Attempting to remove or test for the presence of an element that violates an implementation's restrictions can result in an exception. Some restricted collections permit this usage. Collection Implementations Classes that implement the collection interfaces typically have names in the form of <Implementation-style><Interface>. The general purpose implementations are summarized in the following table: The general-purpose implementations support all of theoptional operationsin the collection interfaces and have no restrictions on the elements they may contain. They are unsynchronized, but theCollectionsclass contains static factories calledsynchronization wrappersthat can be used to add synchronization to many unsynchronized collections. All of the new implementations havefail-fast iterators, which detect invalid concurrent modification, and fail quickly and cleanly (rather than behaving erratically). TheAbstractCollection,AbstractSet,AbstractList,AbstractSequentialListandAbstractMapclasses provide basic implementations of the core collection interfaces, to minimize the effort required to implement them. The API documentation for these classes describes precisely how each method is implemented so the implementer knows which methods must be overridden, given the performance of the basic operations of a specific implementation. Concurrent Collections Applications that use collections from more than one thread must be carefully programmed. In general, this is known asconcurrent programming. The Java platform includes extensive support for concurrent programming. SeeJava Concurrency Utilitiesfor details. Collections are so frequently used that various concurrent friendly interfaces and implementations of collections are included in the APIs. These types go beyond the synchronization wrappers discussed previously to provide features that are frequently needed in concurrent programming. These concurrent-aware interfaces are available: BlockingQueue TransferQueue BlockingDeque ConcurrentMap ConcurrentNavigableMap The following concurrent-aware implementation classes are available. See the API documentation for the correct usage of these implementations. LinkedBlockingQueue ArrayBlockingQueue PriorityBlockingQueue DelayQueue SynchronousQueue LinkedBlockingDeque LinkedTransferQueue CopyOnWriteArrayList CopyOnWriteArraySet ConcurrentSkipListSet ConcurrentHashMap ConcurrentSkipListMap Design Goals The main design goal was to produce an API that was small in size and, more importantly, in "conceptual weight." It was critical that the new functionality not seem too different to current Java programmers; it had to augment current facilities, rather than replace them. At the same time, the new API had to be powerful enough to provide all the advantages described previously. To keep the number of core interfaces small, the interfaces do not attempt to capture such subtle distinctions as mutability, modifiability, and resizability. Instead, certain calls in the core interfaces areoptional, enabling implementations to throw anUnsupportedOperationExceptionto indicate that they do not support a specified optional operation. Collection implementers must clearly document which optional operations are supported by an implementation. To keep the number of methods in each core interface small, an interface contains a method only if either: It is a trulyfundamental operation: a basic operations in terms of which others could be reasonably defined, There is a compelling performance reason why an important implementation would want to override it. It was critical that all reasonable representations of collections interoperate well. This included arrays, which cannot be made to implement theCollectioninterface directly without changing the language. Thus, the framework includes methods to enable collections to be moved into arrays, arrays to be viewed as collections, and maps to be viewed as collections. Copyright ©1993, 2018, Oracle and/or its affiliates. All rights reserved. Contact Us

资源下载

更多资源
优质分享App

优质分享App

近一个月的开发和优化,本站点的第一个app全新上线。该app采用极致压缩,本体才4.36MB。系统里面做了大量数据访问、缓存优化。方便用户在手机上查看文章。后续会推出HarmonyOS的适配版本。

Mario

Mario

马里奥是站在游戏界顶峰的超人气多面角色。马里奥靠吃蘑菇成长,特征是大鼻子、头戴帽子、身穿背带裤,还留着胡子。与他的双胞胎兄弟路易基一起,长年担任任天堂的招牌角色。

Spring

Spring

Spring框架(Spring Framework)是由Rod Johnson于2002年提出的开源Java企业级应用框架,旨在通过使用JavaBean替代传统EJB实现方式降低企业级编程开发的复杂性。该框架基于简单性、可测试性和松耦合性设计理念,提供核心容器、应用上下文、数据访问集成等模块,支持整合Hibernate、Struts等第三方框架,其适用范围不仅限于服务器端开发,绝大多数Java应用均可从中受益。

Rocky Linux

Rocky Linux

Rocky Linux(中文名:洛基)是由Gregory Kurtzer于2020年12月发起的企业级Linux发行版,作为CentOS稳定版停止维护后与RHEL(Red Hat Enterprise Linux)完全兼容的开源替代方案,由社区拥有并管理,支持x86_64、aarch64等架构。其通过重新编译RHEL源代码提供长期稳定性,采用模块化包装和SELinux安全架构,默认包含GNOME桌面环境及XFS文件系统,支持十年生命周期更新。

用户登录
用户注册
修改密码
忘记密码