- 浏览: 207941 次
文章分类
最新评论
-
qinzl_1:
能举一些代码实例吗?
Apache VFS(2):文件的监听和监控 -
skyuck:
java9920 写道写得很清晰,很不错!我想问一下,如果可以 ...
Jackrabbit的简单节点定义文件格式 -
caoyangx:
roki 写道新书推荐!清华出版社新书《搜索引擎零距离》
购 ...
Apache Solr 介绍(1) -
PointOnLine:
再 顶 。
Apache VFS(4): 事件 -
PointOnLine:
再 顶 。
Apache VFS(3): 文件过滤器和选择器
- 在模块的JAR文件的META-INF/services目录下增加文件条目
- 在系统文件系统下的某目录下增加文件
- 在模块的manifest文件中增加manifest条目
- 实现org.openide.modules.ModuleInstall类并且在manifest文件中配置, 这种方式是在系统启动时执行Java代码
具体情况具体分析:
如果我们正在实现其他模块提供的API, 那么这个模块应该告诉我们如何做. 如果它告诉你应该使用默认的lookup查询, 那么这就意味着使用META-INF/services机制.
如果我们正在定义自己开发的模块的API, 其他模块将实现这个API并且提供自己的类(想一下IDE的Navigator组件,不同的模块注册句柄能够按照不同的文件类型显示Navigator工具), 那么,很明显,基于manifest的注册机制首先就不在考虑范围之内, 因为在manifest条目中无法增加新类型. 程式化的注册机制也是能不用就不用, 因为弹性太差. 所以只剩下 META-INF/services机制或者系统文件系统机制. 我们可以考虑几个问题:
Is this just a simple interface or abstract class people should implement, and I just have to find them all and use them?
A: If so, use META-INF/services
Q: Will all of the objects other modules will register be used at the same time, or are there subsets for specific contexts?
A: This pertains to performance and scalability - wherever possible, you want to avoid actually instantiating the objects other modules install, and delay instantiating them until they really need to be used. Opening module jars and classloading are both expensive operations that slow things down.
If there will potentially be a large number of subclasses of your interface, try to find a way to divide them into context-appropriate categories and use folders in the system filesystem to partition contexts. For example, if you define the interface Eater, and modules will implement eaters of various foods, you probably should create folders for different general kinds of food. That way, you don't have to load a bunch of classes and create the OliveEater, BreadEater, EggEater and SausageEater just to ask them if they can eat the Pizza you came across.
Q: Is there information needed about how each object is to be used which could be provided declaratively, without instantiating the object?
A: If so, use the system filesystem, and either let modules declare file attributes thatprovide additional information, or let modules put their objects in subfolders that have contextual meaning (the same way the folder Loaders/text/x-java uses the folder path to indicate the data type objects pertain to).
Q: How many modules will actually implement my interface? How many objects from other modules will I typically be dealing with? Do I need to instantiate all of them just to display a list in the UI?
A: Displaying things in the UI is a particularly important case: You do not want to have to load a bunch of classes from a module just to show an icon and a display name for something - this pertains to anything you're going to display in the Options dialog, on Menus, or various other views.
You can solve this by using .instance files and asking that modules implementing your API use the file attributes defined for .instance files to declare the icon and display name. Then your code can just get a FileObject for each registered instance, call DataObject.find(theFileObject).getNodeDelegate().getIcon() or getDisplayName() to get the icon or display name of the object without ever having to create the object until it needs to do real work.
If you run the risk of having to instantiate all the objects in a folder just do trivial tests such as finding out how many objects of one class are in a given folder (which may contain objects of other classes), consider recommending .settings files instead of .instance files in your folders.
发表评论
-
Netbeans平台: 顶层组件
2007-06-25 15:09 2031Netbeans平台的顶层组件:org.openide.win ... -
Netbeans平台: 数据对象
2007-06-25 14:52 1419数据对象是文件对象的 ... -
Netbeans平台: .shadow文件
2007-06-25 10:59 1407Netbeans平台中, .shadow文件主要用于系统文件 ... -
Netbeans平台: 声明式的安装 VS 程序式的安装
2007-06-25 09:31 1667在很久很久以前, Netbeans中的大部分对象都是在启动的时 ... -
Netbeans平台: 模块是如何影响系统的?
2007-06-25 09:05 1347Netbeans平台中的模块包含两个重要的内容,一个是配置数据 ... -
Netbeans平台: 窗口系统
2007-06-22 17:04 2253Netbeans平台中窗口系统负责创建主应用窗口,能够在用户界 ... -
Netbeans平台: .setting文件
2007-06-22 16:37 1347.settings files are similar to ... -
Netbeans平台: .instance文件
2007-06-22 16:32 1444Netbeans平台中有.instance文件这个概念. 实际 ... -
Netbeans平台: 文件对象
2007-06-22 16:10 1500Netbeans平台中的文件对象(FileObject)是存在 ... -
Netbeans平台: 文件的识别
2007-06-22 15:16 1673很多应用程序通过用户界面来显示目录和文件, Netbeans用 ... -
Netbeans平台:系统文件系统
2007-06-22 14:18 1739Netbeans平台中有一个概念: System FileSy ... -
Netbeans平台的API: 数据系统(Datasystem API)
2007-06-18 14:07 1288Netbeans平台的数据系统 ... -
Netbeans平台的API: 节点API(Node)
2007-06-18 10:37 2147Netbeans使用Node将JavaBeans或者其他具备属 ... -
Netbeans平台的API们
2007-06-18 10:05 2511Netbeans平台上开发富客户端需要仔细研究他的API,这里 ... -
Netbeans平台的一些概念和基础知识
2007-06-11 13:17 1551开发Netbeans RCP前需要一些基础知识: 原文 ... -
Visual Web Pack 的背后(1)
2007-04-02 10:02 70Visual Web Pack 大概是Netbeans5以来最 ... -
Two examples for Netbeans Platform Application
2007-01-30 16:33 1420http://www.ociweb.com/jnb/ ... -
Netbeans API
2007-01-18 17:29 105Netbeans API 是用来基于Netbeans平台开发R ... -
NetBeans中使用Java Persistence API
2006-12-26 15:20 101JPA是EJB3.0的规范之一。本文章将描述如何使用Netbe ... -
Visual Web Pack面板
2006-12-22 17:15 1745Visual Web Pack是Netbeans5.5的一个卖 ...
相关推荐
Written for Java™ developers of varying skill and familiarity with the open source NetBeans™ IDE as well as Java IDEs in general, Pro NetBeans™ IDE 5.5 Enterprise Edition focuses on using ...
语言程序设计资料:NetBeans使用教程.doc
Apache NetBeans是一个开源开发环境,工具平台和应用程序框架。 建造状态 GitHub动作 TravisCI: Apache Jenkins: Linux: 视窗: 要求 吉特 蚂蚁1.9.9或以上 JDK 8或11(用于构建NetBeans) JDK 9或更高版本...
如何使用NetBeans编译Java程序.
语言程序设计资料:第13章_开发工具:NetBeans的使用.ppt
NetBeans+IDE+使用说明和示例教程.pdf
NetBeans是新近流行的一款堪与Eclipse媲美的IDE,有Sun的支持。下面是NetBeans使用教程入门篇。
Netbeans 平台示例 在这里,您将找到完整的基于 Netbeans 平台的应用程序演示,了解如何完成不同的标准应用程序功能。 它远未完成或准备用作大多数事情的示例,但它是讨论的开始,并希望有一些社区参与。 :-) 参加...
netbeans8:Netybeans产品8
NetBeans使用手册.pdf,有兴趣的朋可以参考一下,很有用的。
NetBeans不仅可以作为Java开发工具,还可以使用它开发标准的Java程序、Web应用程序、Java EE企业级应用程序、Java ME手机应用程序等,还能够开发C++程序、Ruby程序等。 本书主要介绍NetBeans 6.0简体中文版集成...
使用NetBeans开发J2ME应用程序
《NetBeans权威指南》主要介绍NetBeans 6.0简体中文版集成开发环境的基本功能和使用方法。读者在阅读《NetBeans权威指南》的同时,不仅能够掌握NetBeans的使用方法,还能够学习如何进行项目的开发。《NetBeans权威...
在Netbeans中使用Struts2.0+Spring2.5+Hibernate框
netbeans使用方法,里边是学习java时使用netbeans的心得,经验之谈。
这适合初级学习netbeans的学者使用 很基本的东西希望给迷茫中的你一分帮助 如果需要更多的netbeans的教程或是方法可以直接联系我 Q 281800171
netbeans使用各种对话框的例子
Apache-NetBeans 21安装包
JAVA基于NETBEANS平台的水仙花数的编写