1
<?xml version="1.0" encoding="UTF-8"?>
2
<!DOCTYPE api-answers PUBLIC "-//NetBeans//DTD Arch Answers//EN" "../../../nbbuild/antsrc/org/netbeans/nbbuild/Arch.dtd" [
3
<!ENTITY api-questions SYSTEM "../../../nbbuild/antsrc/org/netbeans/nbbuild/Arch-api-questions.xml">
7
question-version="1.29"
8
author="mroskanin@netbeans.org"
15
<question id="arch-what" when="init">
16
What is this project good for?
18
Please provide here a few lines describing the project,
19
what problem it should solve, provide links to documentation,
24
<answer id="arch-what">
26
The legacy settings system in the editor module is complicated, error prone
27
and hard to use. It'd been created spontaneously over the years to support
28
immediate needs at that time without paying enough attention to extensibility
29
and interoperability. Historically any module providing editor settings needed
30
to depend on the whole editor module.
33
The main purpose of this project is to define API for editor settings, that
34
is lightweight and easily extensible. The API relies on <code>MimeLookup</code>
35
to provide a way of registering and looking up settings.
36
The aim is NOT to provide an implementation of a storage for editor settings,
37
but to define an interface between this storage and clients
38
like <mime-type> editors, externaleditor, etc.
44
<question id="arch-overall" when="init">
45
Describe the overall architecture.
48
<a href="http://openide.netbeans.org/tutorial/api-design.html#design.apiandspi">
49
clients and what support API</a>?
50
What parts will be pluggable?
51
How will plug-ins be registered? Please use <code><api type="export"/></code>
52
to describe your general APIs.
53
If possible please provide
58
<answer id="arch-overall">
61
The <code>editor/settings</code> module consists of several
62
<api name="EditorSettingsAPI" group="java" type="export" category="official">API</api>
63
classes for accessing editor related settings. The classes are stored in the
64
<code>org.netbeans.api.editor.settings</code> package. Each class is responsible
65
for a different group of settings:
70
<a href="@org-netbeans-modules-editor-settings@/org/netbeans/api/editor/settings/FontColorSettings.html">FontColorSettings</a> -
71
the map of names (i.e. <code>String</code>s) of colorings and their parameters
72
(i.e. <code>AttributeSet</code>s).
75
<a href="@org-netbeans-modules-editor-settings@/org/netbeans/api/editor/settings/CodeTemplateSettings.html">CodeTemplateSettings</a> -
76
the map of template names (i.e. <code>String</code>s) and their bodies
77
(i.e. <code>String</code>s).
80
<a href="@org-netbeans-modules-editor-settings@/org/netbeans/api/editor/settings/KeyBindingSettings.html">KeyBindingSettings</a> -
82
<code><a href="@org-netbeans-modules-editor-settings@/org/netbeans/api/editor/settings/MultiKeyBinding.html">MultiKeyBinding</a></code>s.
83
Each <code>MultiKeyBinding</code> is a list of keyboard shortcuts associated
84
to an <code>Action</code>.
89
Editor settings for a particular mime type can be obtained through <code>MimeLookup</code>
92
MimePath mimePath = MimePath.parse("text/x-java");
93
FontColorSettings fcs = (FontColorSettings) MimeLookup.getLookup(mimePath).lookup(FontColorSettings.class);
101
<question id="arch-quality" when="init">
102
How will the <a href="http://www.netbeans.org/community/guidelines/q-evangelism.html">quality</a>
103
of your code be tested and
104
how are future regressions going to be prevented?
106
What kind of testing do
107
you want to use? How much functionality, in which areas,
108
should be covered by the tests?
112
<answer id="arch-quality">
113
There are unit tests available covering the module's functionality.
119
<question id="arch-time" when="init">
120
What are the time estimates of the work?
122
Please express your estimates of how long the design, implementation,
123
stabilization are likely to last. How many people will be needed to
124
implement this and what is the expected milestone by which the work should be
129
<answer id="arch-time">
130
The modules is available in CVS trunk.
136
<question id="arch-usecases" when="init">
137
Describe the main <a href="http://openide.netbeans.org/tutorial/api-design.html#usecase">
138
use cases</a> of the new API. Who will use it under
139
what circumstances? What kind of code would typically need to be written
143
<answer id="arch-usecases">
145
<usecase id="accessing-settings" name="Accessing settings">
147
All editor settings are mime type specific and therefore should be retrieved
148
using <code>MimeLookup</code>. The following example shows how to retrieve
149
the <code>FontColorSettings</code> for java files and how to get <code>AttributeSet</code>
150
with coloring attributes for a particular coloring (i.e. in this case the
151
colors used for highlighting selected text)
155
MimePath mimePath = MimePath.parse("text/x-java");
156
FontColorSettings fcs = (FontColorSettings) MimeLookup.getLookup(mimePath).lookup(FontColorSettings.class);
157
AttributeSet coloring = fcs.getFontColors(FontColorNames.SELECTION_COLORING);
161
<usecase id="listening-on-changes" name="Listening on changes">
163
If clients need to react on changes in editor settings they can attach <code>LookupListener</code>
164
to the <code>LookupResult</code> they got for their particular settings class
165
from <code>MimeLookup</code>. The following example shows how to do it.
169
MimePath mimePath = MimePath.parse("text/x-java");
170
Lookup lookup = MimeLookup.getLookup(mimePath);
171
LookupResult result = lookup.lookup(new Lookup.Template(FontColorSettings.class));
173
result.addLookupListener(new LookupListener() {
174
public void resultChanged(LookupEvent ev) {
175
//... the client's response to the settings change
181
The <code>FontColorSettings</code> class implementor is responsible and will create
182
a new instance of <code>FontColorSettings</code> whenever some coloring will change.
183
This new instance will be placed in <code>MimeLookup</code> replacing the old one.
190
<question id="compat-i18n" when="impl">
191
Is your module correctly internationalized?
193
Correct internationalization means that it obeys instructions
194
at <a href="http://www.netbeans.org/download/dev/javadoc/OpenAPIs/org/openide/doc-files/i18n-branding.html">
195
NetBeans I18N pages</a>.
199
<answer id="compat-i18n">
206
<question id="compat-standards" when="init">
207
Does the module implement or define any standards? Is the
208
implementation exact or does it deviate somehow?
211
<answer id="compat-standards">
212
Compatible with standards.
218
<question id="compat-version" when="impl">
219
Can your module coexist with earlier and future
220
versions of itself? Can you correctly read all old settings? Will future
221
versions be able to read your current settings? Can you read
222
or politely ignore settings stored by a future version?
225
Very helpful for reading settings is to store version number
226
there, so future versions can decide whether how to read/convert
227
the settings and older versions can ignore the new ones.
231
<answer id="compat-version">
232
No persistance is used for editor/settings module.
238
<question id="dep-jre" when="final">
239
Which version of JRE do you need (1.2, 1.3, 1.4, etc.)?
241
It is expected that if your module runs on 1.x that it will run
242
on 1.x+1 if no, state that please. Also describe here cases where
243
you run different code on different versions of JRE and why.
247
<answer id="dep-jre">
248
JDK1.4 and higher can be used.
254
<question id="dep-jrejdk" when="final">
255
Do you require the JDK or is the JRE enough?
258
<answer id="dep-jrejdk">
265
<question id="dep-nb" when="init">
266
What other NetBeans projects and modules does this one depend on?
268
If you want, describe such projects as imported APIs using
269
the <code><api name="identification" type="import or export" category="stable" url="where is the description" /></code>
274
<defaultanswer generate='here'/>
280
<question id="dep-non-nb" when="init">
281
What other projects outside NetBeans does this one depend on?
284
Some non-NetBeans projects are packaged as NetBeans modules
285
(see <a href="http://libs.netbeans.org/">libraries</a>) and
286
it is preferred to use this approach when more modules may
287
depend on such third-party library.
291
<answer id="dep-non-nb">
298
<question id="dep-platform" when="init">
299
On which platforms does your module run? Does it run in the same
302
If your module is using JNI or deals with special differences of
303
OSes like filesystems, etc. please describe here what they are.
307
<answer id="dep-platform">
313
<answer id="deploy-dependencies">
320
<question id="deploy-jar" when="impl">
321
Do you deploy just module JAR file(s) or other files as well?
323
If your module consists of just one module JAR file, just confirm that.
324
If it uses more than one JAR, describe where they are located, how
325
they refer to each other.
326
If it consist of module JAR(s) and other files, please describe
327
what is their purpose, why other files are necessary. Please
328
make sure that installation/uninstallation leaves the system
329
in state as it was before installation.
333
<answer id="deploy-jar">
340
<question id="deploy-nbm" when="impl">
341
Can you deploy an NBM via the Update Center?
347
<answer id="deploy-nbm">
354
<question id="deploy-packages" when="init">
355
Are packages of your module made inaccessible by not declaring them
359
NetBeans module system allows restriction of access rights to
360
public classes of your module from other modules. This prevents
361
unwanted dependencies of others on your code and should be used
362
whenever possible (<a href="http://www.netbeans.org/download/javadoc/OpenAPIs/org/openide/doc-files/upgrade.html#3.4-public-packages">
364
</a>). If you do not restrict access to your classes you are
365
making it too easy for other people to misuse your implementation
366
details, that is why you should have good reason for not
367
restricting package access.
371
<answer id="deploy-packages">
372
Yes, only the API is public. There is no implementation in the editor/settings module.
378
<question id="deploy-shared" when="final">
379
Do you need to be installed in the shared location only, or in the user directory only,
380
or can your module be installed anywhere?
382
Installation location shall not matter, if it does explain why.
383
Consider also whether <code>InstalledFileLocator</code> can help.
387
<answer id="deploy-shared">
394
<question id="exec-classloader" when="impl">
395
Does your code create its own class loader(s)?
397
A bit unusual. Please explain why and what for.
401
<answer id="exec-classloader">
408
<question id="exec-component" when="impl">
409
Is execution of your code influenced by any (string) property
410
of any of your components?
413
Often <code>JComponent.getClientProperty</code>, <code>Action.getValue</code>
414
or <code>PropertyDescriptor.getValue</code>, etc. are used to influence
415
a behavior of some code. This of course forms an interface that should
416
be documented. Also if one depends on some interface that an object
417
implements (<code>component instanceof Runnable</code>) that forms an
422
<answer id="exec-component">
429
<question id="exec-introspection" when="impl">
430
Does your module use any kind of runtime type information (<code>instanceof</code>,
431
work with <code>java.lang.Class</code>, etc.)?
433
Check for cases when you have an object of type A and you also
434
expect it to (possibly) be of type B and do some special action. That
435
should be documented. The same applies on operations in meta-level
436
(Class.isInstance(...), Class.isAssignableFrom(...), etc.).
440
<answer id="exec-introspection">
447
<question id="exec-privateaccess" when="final">
448
Are you aware of any other parts of the system calling some of
449
your methods by reflection?
451
If so, describe the "contract" as an API. Likely private or friend one, but
452
still API and consider rewrite of it.
456
<answer id="exec-privateaccess">
463
<question id="exec-process" when="impl">
464
Do you execute an external process from your module? How do you ensure
465
that the result is the same on different platforms? Do you parse output?
466
Do you depend on result code?
468
If you feed an input, parse the output please declare that as an API.
472
<answer id="exec-process">
479
<question id="exec-property" when="impl">
480
Is execution of your code influenced by any environment or
481
Java system (<code>System.getProperty</code>) property?
484
If there is a property that can change the behavior of your
485
code, somebody will likely use it. You should describe what it does
486
and the <a href="http://openide.netbeans.org/tutorial/api-design.html#life">stability category</a>
487
of this API. You may use
489
<api type="export" group="property" name="id" category="private" url="http://...">
490
description of the property, where it is used, what it influence, etc.
496
<answer id="exec-property">
503
<question id="exec-reflection" when="impl">
504
Does your code use Java Reflection to execute other code?
506
This usually indicates a missing or insufficient API in the other
507
part of the system. If the other side is not aware of your dependency
508
this contract can be easily broken.
512
<answer id="exec-reflection">
519
<question id="exec-threading" when="impl">
520
What threading models, if any, does your module adhere to?
522
If your module calls foreign APIs which have a specific threading model,
523
indicate how you comply with the requirements for multithreaded access
524
(synchronization, mutexes, etc.) applicable to those APIs.
525
If your module defines any APIs, or has complex internal structures
526
that might be used from multiple threads, declare how you protect
527
data against concurrent access, race conditions, deadlocks, etc.,
528
and whether such rules are enforced by runtime warnings, errors, assertions, etc.
529
Examples: a class might be non-thread-safe (like Java Collections); might
530
be fully thread-safe (internal locking); might require access through a mutex
531
(and may or may not automatically acquire that mutex on behalf of a client method);
532
might be able to run only in the event queue; etc.
533
Also describe when any events are fired: synchronously, asynchronously, etc.
534
Ideas: <a href="http://core.netbeans.org/proposals/threading/index.html#recommendations">Threading Recommendations</a> (in progress)
538
<answer id="exec-threading">
539
No special threading models used.
545
<question id="format-clipboard" when="impl">
546
Which data flavors (if any) does your code read from or insert to
547
the clipboard (by access to clipboard on means calling methods on <code>java.awt.datatransfer.Transferable</code>?
550
Often Node's deal with clipboard by usage of <code>Node.clipboardCopy, Node.clipboardCut and Node.pasteTypes</code>.
551
Check your code for overriding these methods.
555
<answer id="format-clipboard">
556
No clipboard support.
562
<question id="format-dnd" when="impl">
563
Which protocols (if any) does your code understand during Drag & Drop?
565
Often Node's deal with clipboard by usage of <code>Node.drag, Node.getDropType</code>.
566
Check your code for overriding these methods. Btw. if they are not overridden, they
567
by default delegate to <code>Node.clipboardCopy, Node.clipboardCut and Node.pasteTypes</code>.
571
<answer id="format-dnd">
578
<question id="format-types" when="impl">
579
Which protocols and file formats (if any) does your module read or write on disk,
580
or transmit or receive over the network?
583
<answer id="format-types">
584
No files read or written to the disk.
590
<question id="lookup-lookup" when="init">
591
Does your module use <code>org.openide.util.Lookup</code>
592
or any similar technology to find any components to communicate with? Which ones?
595
Please describe the interfaces you are searching for, where
596
are defined, whether you are searching for just one or more of them,
597
if the order is important, etc. Also classify the stability of such
602
<answer id="lookup-lookup">
603
No. It only defines the classes that can be looked up via MimeLookup.
609
<question id="lookup-register" when="final">
610
Do you register anything into lookup for other code to find?
612
Do you register using layer file or using <code>META-INF/services</code>?
613
Who is supposed to find your component?
617
<answer id="lookup-register">
624
<question id="lookup-remove" when="final">
625
Do you remove entries of other modules from lookup?
627
Why? Of course, that is possible, but it can be dangerous. Is the module
628
your are masking resource from aware of what you are doing?
632
<answer id="lookup-remove">
639
<question id="perf-exit" when="final">
640
Does your module run any code on exit?
643
<answer id="perf-exit">
650
<question id="perf-huge_dialogs" when="final">
651
Does your module contain any dialogs or wizards with a large number of
652
GUI controls such as combo boxes, lists, trees, or text areas?
655
<answer id="perf-huge_dialogs">
662
<question id="perf-limit" when="init">
663
Are there any hard-coded or practical limits in the number or size of
664
elements your code can handle?
667
<answer id="perf-limit">
674
<question id="perf-mem" when="final">
675
How much memory does your component consume? Estimate
676
with a relation to the number of windows, etc.
679
<answer id="perf-mem">
680
No specific memory usage.
686
<question id="perf-menus" when="final">
687
Does your module use dynamically updated context menus, or
688
context-sensitive actions with complicated enablement logic?
691
<answer id="perf-menus">
698
<question id="perf-progress" when="final">
699
Does your module execute any long-running tasks?
701
<hint>Long running tasks should never block
702
AWT thread as it badly hurts the UI
703
<a href="http://performance.netbeans.org/responsiveness/issues.html">
705
Tasks like connecting over
706
network, computing huge amount of data, compilation
707
be done asynchronously (for example
708
using <code>RequestProcessor</code>), definitively it should
709
not block AWT thread.
713
<answer id="perf-progress">
720
<question id="perf-scale" when="init">
721
Which external criteria influence the performance of your
722
program (size of file in editor, number of files in menu,
723
in source directory, etc.) and how well your code scales?
725
Please include some estimates, there are other more detailed
726
questions to answer in later phases of implementation.
730
<answer id="perf-scale">
731
There is no performance sensitive code in editor/settings module.
737
<question id="perf-spi" when="init">
738
How the performance of the plugged in code will be enforced?
740
If you allow foreign code to be plugged into your own module, how
741
do you enforce that it will behave correctly and quickly and will not
742
negatively influence the performance of your own module?
746
<answer id="perf-spi">
753
<question id="perf-startup" when="final">
754
Does your module run any code on startup?
757
<answer id="perf-startup">
764
<question id="perf-wakeup" when="final">
765
Does any piece of your code wake up periodically and do something
766
even when the system is otherwise idle (no user interaction)?
769
<answer id="perf-wakeup">
776
<question id="resources-file" when="final">
777
Does your module use <code>java.io.File</code> directly?
780
NetBeans provide a logical wrapper over plain files called
781
<code>org.openide.filesystems.FileObject</code> that
782
provides uniform access to such resources and is the preferred
783
way that should be used. But of course there can be situations when
784
this is not suitable.
788
<answer id="resources-file">
795
<question id="resources-layer" when="final">
796
Does your module provide own layer? Does it create any files or
797
folders in it? What it is trying to communicate by that and with which
801
NetBeans allows automatic and declarative installation of resources
802
by module layers. Module register files into appropriate places
803
and other components use that information to perform their task
804
(build menu, toolbar, window layout, list of templates, set of
809
<answer id="resources-layer">
816
<question id="resources-mask" when="final">
817
Does your module mask/hide/override any resources provided by other modules in
821
If you mask a file provided by another module, you probably depend
822
on that and do not want the other module to (for example) change
823
the file's name. That module shall thus make that file available as an API
824
of some stability category.
828
<answer id="resources-mask">
835
<question id="resources-read" when="final">
836
Does your module read any resources from layers? For what purpose?
839
As this is some kind of intermodule dependency, it is a kind of API.
840
Please describe it and classify according to
841
<a href="http://openide.netbeans.org/tutorial/api-design.html#categories">
842
common stability categories</a>.
846
<answer id="resources-read">
853
<question id="security-grant" when="final">
854
Does your code grant addition rights to some code?
855
<hint>Avoid using a classloder that adds some extra
856
permissions to loaded code unless realy necessary.
857
Also note that your API implementation
858
can also expose unneeded permissions to enemy code by
859
AccessController.doPrilileged() calls.</hint>
862
<answer id="security-grant">
869
<question id="security-policy" when="final">
870
Does your functionality require standard policy file modification?
871
<hint>Your code may pass control to third party code not
872
coming from trusted domain. It covers code downloaded over
873
network or code coming from libraries that are not bundled
874
with NetBeans. Which permissions it needs to grant to which domain?</hint>
877
<answer id="security-policy">
883
<question id="exec-ant-tasks" when="impl">
884
Do you define or register any ant tasks that other can use?
887
If you provide an ant task that users can use, you need to be very
888
careful about its syntax and behaviour, as it most likely forms an
889
API for end users and as there is a lot of end users, their reaction
890
when such API gets broken can be pretty strong.
894
<answer id="exec-ant-tasks">
906
<question id="arch-where" when="impl">
907
Where one can find sources for your module?
909
Please provide link to the CVS web client at
910
http://www.netbeans.org/download/source_browse.html
911
or just use tag defaultanswer generate='here'
915
<answer id="arch-where">
916
<defaultanswer generate='here' />
922
<question id="compat-deprecation" when="init">
923
How the introduction of your project influences functionality
924
provided by previous version of the product?
926
If you are planning to deprecate/remove/change any existing APIs,
927
list them here accompanied with the reason explaining why you
932
<answer id="compat-deprecation">
939
<question id="resources-preferences" when="final">
940
Does your module uses preferences via Preferences API? Does your module use NbPreferences or
941
or regular JDK Preferences ? Does it read, write or both ?
942
Does it share preferences with other modules ? If so, then why ?
945
<pre xml:space="preserve">
946
<api type="export" group="preferences"
947
name="preference node's absolute path name" category="private" url="http://...">
948
description of individual keys, where it is used, what it
949
influence, whether the module reads/write it, etc.
955
<answer id="resources-preferences">