`
alartin
  • 浏览: 210227 次
社区版块
存档分类
最新评论

Netbeans平台: .setting文件

阅读更多
.settings files are similar to .instance files, with the distinction that they specify all the superclasses/interfaces of the object represented, so that some code can ask Lookup/whatever "Do you have one of these?" without needing to actually create an instance of the object. You could call .settings files "POJO persistence".

They had a brief run of popularity as Yet Another Way To Store Settings a few years ago, around when the new window system was being conceived. They're not bad, but a bit baroque. The main point was to avoid loading classes or creating objects just to satisfy a test like "how many object instances are there of X", "does this folder/lookup/collection contain an instance of X". For NetBeans, where there are lots of classes, this sort of thing really does make a difference in performance. The observation was that huge amounts of classloading could be triggered just to find out that something was not actually of use to whatever code triggered it to be instantiated.

.settings files can be used for the same purposes as .instance files - as a way of indicating that the file represents some class that should be instantiated. The main difference is that by defining all of the superclasses and interfaces of the the object they represent, it is possible for the system to delay actually instantiating the object longer - more questions about the object can be answered by the system without creating it to answer those questions.

.settings files are typically not used for registering actions in the main menu and similar places, since these actions will need to be instantiated almost immediately anyway in order to determine if they should be enabled or not. A future API for declarative actions will possibly change that, but at present, it does neither harm more good, and .instance files are simpler (and for cases where the object will be instatiated immediately anyway, faster).

Some examples:

Declaring a system option as a .settings file from an XML layer

Have a layer entry such as this:
  <folder name="Services">
<file name="org-openide-text-PrintSettings.settings" url="PrintSettings.settings">
<attr name="SystemFileSystem.localizingBundle" stringvalue="org.netbeans.core.Bundle"/>
<attr name="SystemFileSystem.icon" urlvalue="nbresloc:/org/openide/resources/printSettings.gif"/>
</file>
</folder>

Note the url attribute - it points to a file PrintSettings.settings which is in the same directory in the module jar as the layer file - it is a relative path. That settings file will look like this:

  <?xml version="1.0"?>
<!DOCTYPE settings PUBLIC "-//NetBeans//DTD Session settings 1.0//EN" "http://www.netbeans.org/dtds/sessionsettings-1_0.dtd">
<settings version="1.0">
<instanceof class="java.beans.beancontext.BeanContextProxy"/>
<instanceof class="org.openide.util.SharedClassObject"/>
<instanceof class="org.openide.options.SystemOption"/>
<instanceof class="org.openide.options.ContextSystemOption"/>
<instanceof class="org.openide.text.PrintSettings"/>
<instance class="org.openide.text.PrintSettings"/>
</settings>

The two things to note are that the .settings file declares many of the relevant parent classes of the object (so it does not need to be instantiated just to see what kind of object it is), and the layer file declares the icon and a resource bundle (for the display name) as file attributes .

分享到:
评论

相关推荐

    netbeans字体配置文件.netbeans字体配置文件

    netbeans字体配置文件.netbeans字体配置文件netbeans字体配置文件.netbeans字体配置文件netbeans字体配置文件.netbeans字体配置文件netbeans字体配置文件.netbeans字体配置文件netbeans字体配置文件.netbeans字体...

    org.netbeans.lib.axtextra

    在压缩包子文件的文件名称列表中仅列出 "org",这可能表示整个库的结构,其中包含了 `org.netbeans.lib.axtextra` 包下的所有源代码、类文件和其他资源。通常,这样的目录结构意味着库包含了多个类和相关支持文件,...

    语言程序设计资料:第13章_开发工具:NetBeans的使用.ppt

    语言程序设计资料:第13章_开发工具:NetBeans的使用.ppt

    Pro.Netbeans.IDE.6.Rich.Client.Platform.Edition

    《Pro.Netbeans.IDE.6.Rich.Client.Platform.Edition》是针对NetBeans IDE 6的深入教程,专注于富客户端平台(Rich Client Platform)的开发。NetBeans IDE是一款强大的开源集成开发环境,尤其在Java开发领域备受...

    语言程序设计资料:NetBeans使用文档.doc

    语言程序设计资料:NetBeans使用文档.doc

    语言程序设计资料:NetBeans学习笔记.doc

    语言程序设计资料:NetBeans学习笔记.doc

    NetBeans.Platform.6.9.Developers.Guide

    - **Swing 在 NetBeans Platform 中的作用**:NetBeans Platform 6.9 提供了一个专门为 Swing 设计的应用程序框架,这意味着开发者可以利用平台提供的工具和服务来简化 Swing 应用程序的开发过程。 - **框架优势**:...

    Netbeans.教程.doc编程资料

    Netbeans.教程.doc

    NetBeans图书:Pro NetBeans IDE 5.5 Enterprise Edition

    一共分两卷,这是第二部分。... you'll find what you need in this book to get started with the more vibrant, more productive extensible NetBeans platform project found on netbeans.org.

    Java-netbeans-7.rar

    在使用Java-netbeans-7.rar这个压缩包时,解压后将得到NetBeans 7的安装文件,按照安装向导步骤即可完成安装。安装完成后,你可以开始利用NetBeans 7的全部功能来编写、调试和部署Java应用程序。无论是初学者还是...

    The.Definitive.Guide.to.NetBeans.Platform.7.pdf.rar

    《The Definitive Guide to NetBeans Platform 7》是一本由NetBeans官方网站提供的权威Java开发指南,这本书深入探讨了NetBeans Platform 7的各种特性和功能,旨在帮助开发者充分利用这一强大的开发平台进行应用程序...

    NetBeans.Platform.6.9.Developers.Guide的代码

    总的来说,NetBeans.Platform.6.9.Developers.Guide提供了全面的指导,让开发者能够有效地利用NetBeans构建模块化、基于Petri网的任务管理应用。通过深入学习这个指南和实践其中的代码,开发者不仅可以提升在...

    语言程序设计资料:NetBeans使用教程.doc

    NetBeans 是一个流行的集成开发环境(IDE),它提供了一个功能强大且灵活的平台 для开发 Java 应用程序。在本教程中,我们将学习如何使用 NetBeans 创建一个 Java 应用程序,并编写用于测试的 JavaBean 和测试...

    [The.Definitive.Guide.to.NetBeans.Platform.7].Heiko.B&ouml;ck.文字版.pdf

    《NetBeans平台终极指南》是Heiko Böck编著的一本详尽的书籍,旨在为读者提供关于NetBeans平台的全面理解与深入洞察。本书不仅涵盖了NetBeans平台的基础概念和核心架构,还深入探讨了如何开发用户界面、利用标准...

    netbeans64位.zip

    - NetBeans支持创建、管理和组织多个项目,每个项目可以包含源代码、资源文件、库引用等。 - 它还支持版本控制系统如Git,方便团队协作和代码版本控制。 4. **Maven和Ant支持**: - 对于Java项目,NetBeans可以...

    NetBeans.IDE.7.Cookbook

    - **解决方案**:关闭不必要的背景任务,减少打开的文件数量,考虑增加系统的RAM。 #### 四、高级功能详解 - **版本控制集成**:NetBeans IDE 7 支持多种版本控制系统(如SVN、Git等),便于团队协作和代码管理。...

    Apress,.Pro.Netbeans.IDE.6.Rich.Client.Platform.Edition.(2008).rar

    《Apress Pro NetBeans IDE 6 Rich Client Platform Edition (2008)》是一本专为开发者准备的指南,详细介绍了如何使用NetBeans IDE 6来构建富客户端平台应用程序。这本书由Apress出版社出版,旨在帮助程序员充分...

Global site tag (gtag.js) - Google Analytics